Created
April 16, 2013 14:27
-
-
Save wnstn/5396331 to your computer and use it in GitHub Desktop.
Wordpress router.php, for using the built in PHP server with WP sites.
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 | |
$root = $_SERVER['DOCUMENT_ROOT']; | |
chdir($root); | |
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/'); | |
if(file_exists($root.$path)) | |
{ | |
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') | |
{ | |
header('location: '.rtrim($path,'/').'/'); | |
exit; | |
} | |
if(strpos($path,'.php') === false) return false; | |
else { | |
chdir(dirname($root.$path)); | |
require_once $root.$path; | |
} | |
}else include_once 'index.php'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment