Question

I want to redirect a file download from

mysite.com/setup.exe to supercoolcdn/setup.exe

I had earlier written some redirect rule myself,but it had resulted in loops and brought the website down eventually.

Can someone suggest me a proper way to do it.

Was it helpful?

Solution

You can use redirect rule like this in your root .htaccess:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ [NC]
RewriteCond ^setup\.exe$ http://cdn.com/downloads%{REQUEST_URI} [L,R=301,NC]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top