I need to redirect URLs of all .dmg
files at domain's top level to specific folder.
By way of example:
http://example.com/file.dmg
to http://example.com/downloads/file.dmg
I can't hard code the domain name because it's a temporary domain which will be switched once the new website is completed.
I don't understand why the following doesn't work:
RewriteRule ^.*\.com/(.*)\.dmg$ /downloads/$1.dmg [R=301,L,NC]
I get "page not found" error. A .htaccess tester website also reports failure.
What am I missing?
It's a WordPress website if it makes any difference.
.com
in the rewrite rule when your example path (file.dmg
) doesn't have it?.com
because I need to redirect files from the top level of the domain. As far as I understand, if I use/file.dmg
it will also apply to the files in the/downloads
folder. I started with this and ran into "too many redirects" error. When it comes to 301 redirect and advanced regex I'm an amateur.