On my website there is a collection of pdf files for manuals, brochures, MSDS etc. The links to download these files are scattered across a "downloads" area, informational pages and product page. We update the brochures on a regular basis so in order to not have to update every single page where the file is linked from I need to know how to create a redirect where the old URL:
http://easypropondproducts.com/media/pdfs/EcoPondKitsBroch-MPF-109.pdf
will permanently redirect to the new URL
http://easypropondproducts.com/media/pdfs/EcoPondKitsBroch-MPF-512.pdf
I have tried custom URL rewrites and it doesn't seem to work how I have configured it: Type: custom ID Path: /media/pdfs/EcoPondKitsBroch-MPF-109.pdf Request Path: /media/pdfs/EcoPondKitsBroch-MPF-109.pdf Target Path: http://easypropondproducts.com/media/pdfs/EcoPondKitsBroch-MPF-512.pdf Redirect: Permanent (301)
What am I doing wrong? Is there any way to do this?
You cannot rewrite files in the media
folder by using Magentos internal URL Rewrite Management.
That's because URLs pointing to Magentos media
(or skin
or js
) folder don't even reach the central entry point at index.php
, but are served directly.
Take a look at Magentos root .htaccess
file:
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
With your URL, the first RewriteCond
is the one that doesn't match. This condition says "if the URL does NOT start with /media/
or /skin/
or /js/
".
But your URL does start with /media/
. Hence it will not be rewritten to index.php
and cannot reach Magentos internal URL Rewrite Management.
To achieve what you want you could insert the following line right before the first RewriteCond
:
Redirect 301 /media/pdfs/EcoPondKitsBroch-MPF-109.pdf /media/pdfs/EcoPondKitsBroch-MPF-512.pdf