Created
April 14, 2015 19:47
-
-
Save sagikazarmark/d262ba75c17061a41d1e to your computer and use it in GitHub Desktop.
PHP server router script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* PHP Server router script | |
*/ | |
// determine the file we're loading, we need to strip the query string for that | |
if (isset($_SERVER['SCRIPT_NAME'])) | |
{ | |
$file = $_SERVER['DOCUMENT_ROOT'].$_SERVER['SCRIPT_NAME']; | |
} | |
else | |
{ | |
$file = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI']; | |
if (($pos = strpos($file, '?')) !== false) | |
{ | |
$file = substr($file, 0, $pos); | |
} | |
} | |
if (file_exists($file)) | |
{ | |
// bypass existing file processing | |
return false; | |
} | |
else | |
{ | |
// route requests though the normal path | |
include($_SERVER['SCRIPT_NAME'] = $_SERVER['DOCUMENT_ROOT'].'/index.php'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment