What is the best way to create 301 redirects on Pantheon for file? I can create redirects for paths by placing rules in my settings.php:
switch ($_SERVER['REQUEST_URI']) {
case '/my-path':
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://mydoamin/my-new-path');
exit();
}
This is the redirect I want to create:
a/b/c/document.pdf
and e/f/g/document2.pdf
both should be redirected to /new/folder/document3.pdf
.
Unfortunately, this won't work with files.
Here is how I test:
Create file
test.txt
in sites/default/filesAccess sites/default/files/test.txt and verify it works
Update settings.php and add
die($_SERVER['REQUEST_URI']);
and verify you the get uri.
Instead of getting URI I get 404.