Skip to content

Instantly share code, notes, and snippets.

@serverok
Created March 31, 2018 17:51
Show Gist options
  • Save serverok/ed0de9915db1297efc13db75db75ebe7 to your computer and use it in GitHub Desktop.
Save serverok/ed0de9915db1297efc13db75db75ebe7 to your computer and use it in GitHub Desktop.
# Handle requests for .php files.
if (strpos($page_name, '.php') !== false) {
if ($page_name == 'index.php') {
HTTP::redirect("/", "301");
} else if ($page_name == 'linux_reseller.php') {
HTTP::redirect("/linux-reseller", "301");
} else if ($page_name == 'dedicated_server.php') {
HTTP::redirect("/dedicated-server", "301");
} else if ($page_name == 'windows_reseller.php') {
HTTP::redirect("/windows-reseller", "301");
} else if ($page_name == 'ffmpeg_hosting.php') {
HTTP::redirect("/ffmpeg-hosting", "301");
} else if ($page_name == 'reseller.php') {
HTTP::redirect("/linux-reseller", "301");
}
$file_path = __DIR__ . '/private/' . $page_name;
if (file_exists($file_path)) {
$page_name = str_replace('.php', '', $page_name);
HTTP::redirect("/$page_name", "301");
}
}
# handle requests with "/" at end.
$needRedirect = false;
if (strpos($page_name, '/') !== false) {
$needRedirect = true;
}
if (preg_match('/([a-z0-9A-Z\-]*)/', $page_name, $matches)) {
$page_name = $matches[1];
}
$file_path = __DIR__ . '/private/' . $page_name . '.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment