Skip to content

Instantly share code, notes, and snippets.

@gnrfan
Created November 25, 2015 00:16
Show Gist options
  • Save gnrfan/2198e0bae816fd40b4fb to your computer and use it in GitHub Desktop.
Save gnrfan/2198e0bae816fd40b4fb to your computer and use it in GitHub Desktop.
Redirects all GET query parameters to given URI.
<?php
define("BASE_URL", 'http://localhost/index.php');
if (array_key_exists('QUERY_STRING', $_SERVER) && strlen(trim($_SERVER['QUERY_STRING']))>0) {
$url = sprintf("%s?%s", BASE_URL, $_SERVER['QUERY_STRING']);
} else {
$url = BASE_URL;
}
header('Status: 301 Moved Permanently', false, 301);
header("Location: $url");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment