Skip to content

Instantly share code, notes, and snippets.

@jsawruk
Created December 15, 2012 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsawruk/4295348 to your computer and use it in GitHub Desktop.
Save jsawruk/4295348 to your computer and use it in GitHub Desktop.
//RewriteCond %{REQUEST_URI} !^/index\.php.* [NC]
//RewriteRule ^(.*)$ /index.php
//RewriteCond %{REQUEST_URI} ^/site [NC]
//RewriteRule site index.php
if ( isset($_SERVER['REDIRECT_URL']) ) {
// REDIRECT_URL - PHP_SELF
// http://localhost/test/ym/something/or/other?woot=1
// '/test/ym/something/or/other' - '/test/index.php'
$path = $_SERVER['REDIRECT_URL'];
$find = $_SERVER['PHP_SELF'];
$pos = strrpos($find,'/');
if ( $pos != '' ){
$find = substr($find, 0, $pos);
$pos = strpos( $path, $find );
$path = substr( $path, $pos+strlen($find) );
}
}
elseif( isset($_SERVER['PATH_INFO']) ) {
// PATH_INFO
// http://localhost/test/index.php/ym/something/or/other?woot=1
// '/ym/something/or/other'
$path = $_SERVER['PATH_INFO'];
}
else {
$path = '';
}
$path = explode('/',ltrim($path,'/'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment