Skip to content

Instantly share code, notes, and snippets.

@ChrisLTD
Created June 28, 2017 00:56
Show Gist options
  • Save ChrisLTD/ee2783a875db16f0b247bc45af5a958e to your computer and use it in GitHub Desktop.
Save ChrisLTD/ee2783a875db16f0b247bc45af5a958e to your computer and use it in GitHub Desktop.
<?php
$redirects = array(
"/aboutus.php" => "/about-us/",
"/blog/2010/02" => "/blog/",
"/blog/2010/04" => "/blog/",
"/blog/2010/07" => "/blog/",
"/blog/2010/12" => "/blog/",
"/blog/2011/01" => "/blog/",
);
// 301 Redirect from /old to /new.
if (array_key_exists($_SERVER['REQUEST_URI'], $redirects) &&
// Check if Drupal or WordPress is running via command line
(php_sapi_name() != "cli")) {
header('HTTP/1.0 301 Moved Permanently');
header('Location: ' . $redirects[$_SERVER['REQUEST_URI']]);
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment