Last active
December 15, 2016 06:08
-
-
Save filipekiss/9178973 to your computer and use it in GitHub Desktop.
A server.php to emulate Apache's mod_rewrite
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 | |
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); | |
$uri = urldecode($uri); | |
$requested = './'.$uri; | |
//Redirect if no trailing slash is found | |
if (substr($uri, -1) !== "/" && !stristr($uri, '.')) { | |
$uri .= "/"; | |
header("Location: ".$uri); | |
} | |
if ($uri !== '/' and file_exists($requested)) | |
{ | |
return false; | |
} | |
require_once 'index.php'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment