Created
May 23, 2014 15:42
-
-
Save bdombro/bf3b96ddf627bd5d8c07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Will parse queries and redirect appropriately | |
// Version 1.0 | |
// Setup .htaccess to redirect certain links here | |
// Example: RedirectMatch /wiki* /legacy_file_redirect.php | |
if(isset($_GET["media"])) { | |
// handle http://dev.americanwhitewater.org/wiki/lib/exe/fetch.php?media=projects:gauley_project.jpg | |
$filename = explode(':',$_GET["media"])[1]; | |
print "redirecting to $filename ... "; | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: /sites/default/files/".$filename); | |
} | |
else { | |
print_r("Error: Did not recognize URL: ".$_SERVER["ORIG_PATH_INFO"]); | |
print_r("Expected a link like americanwhitewater.org/legacy_file_redirect.php?media=projects:1269.pdf"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment