Skip to content

Instantly share code, notes, and snippets.

@koko1000ban
Created August 3, 2012 15:06
Show Gist options
  • Save koko1000ban/3248440 to your computer and use it in GitHub Desktop.
Save koko1000ban/3248440 to your computer and use it in GitHub Desktop.
router.php
<?php
// htaccessのかわり
$real_file = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'];
if (file_exists($real_file)) {
return false;
}
if (!preg_match('/^\/(?:index\.php|images|robots\.txt)/', $_SERVER['REQUEST_URI'])) {
$redirect_url = 'http://' . $_SERVER['HTTP_HOST'] . "/index.php" . $_SERVER['REQUEST_URI'];
/* header("HTTP/1.1 301 Moved Permanently"); */
header("HTTP/1.1 302 Found");
header("Location: $redirect_url");
exit();
} else {
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment