Skip to content

Instantly share code, notes, and snippets.

View br-nhan's full-sized avatar

Nhan Nguyen br-nhan

View GitHub Profile
@br-nhan
br-nhan / readme.md
Created November 26, 2015 04:31 — forked from RaVbaker/readme.md
[HOWTO] Rewrite all urls to one index.php in Apache

Redirect All Requests To Index.php Using .htaccess

In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:

Simple Example

This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

@br-nhan
br-nhan / convert_usable_format.php
Created January 8, 2015 04:31
Convert Japanese CSV [Win | Mac]
<?php
public function convert_usable_format($file){
$buf = mb_convert_encoding(file_get_contents($file), "UTF-8", "SJIS-WIN");
$buf = str_replace(array("\r\n", "\n", "\r"), "m9(^v^)", $buf);
$buf = str_replace("m9(^v^)", "\r\n", $buf);
$handle = tmpfile();
fwrite($handle, $buf);
rewind($handle);