I currently have a PHP file called redirects.php which I am using to redirect particular requests, however I have around 150 pages I need to redirect to different, new pages. My code so far is this:
if (isset($_GET['req'])) {
$req = $_GET['req'];
$redirect = "";
if ($req == "quoter_buying_guides.php") {
$redirect = "newpage";
$loc = "http://www.example.co.uk/" . $redirect;
header("HTTP/1.1 301 Moved Permanently");
header("Location: " .$loc. "");
}
}
Copying the if ($req == "") {... is getting very long winded and making the file rather large. I'd like to be able to do this in one array line for example:
"old-page.php" => "new-page.php
"old-page2.php" => "new-page2.php";
Before anyone mentions using the .htaccess file to perform redirects - I would normally have done however we're using a complicated pager file which ignores 301 requests.