0

I have a temporary need to redirect some installer files on my web site. The redirects that are working now look something like this:

Redirect 302 /installer_1.0.0.zip http://www.example.com/download/installer_1.0.3.zip
Redirect 302 /installer_1.0.1.zip http://www.example.com/download/installer_1.0.3.zip
Redirect 302 /installer_1.0.2.zip http://www.example.com/download/installer_1.0.3.zip

I would like to use a regex instead of having multiple lines for each version I need to redirect. I have tried these options with no success:

Redirect 302 /installer_(.*).zip http://www.example.com/download/installer_1.0.3.zip
Redirect 302 /installer_([0-9+]\.[0-9+]\.[0-9+]).zip http://www.example.com/download/installer_1.0.3.zip

EDIT

I've tried what Joni Salmi has recommended and cannot get it to work. I've tried several iterations of similar rules I've encountered on the web, all to no avail. I feel like I'm missing a fundamental concept here. My .htaccess file on the root of this site has several rules and redirects and they all seem to work just fine. But none is like this, where I have a regex in the middle of an URL string.

Hopefully I can get some more answers from those who have d one this kind of thing in their own projects.

2
  • 2
    You do know that a 301 redirect means it is permanent and will be cached by browsers, proxies and robots? If this is meant to be temporary, you should use a 302 instead. Oct 23, 2013 at 21:32
  • Yes, @user2313067 good point. I grabbed this from another permanent redirect... I will consider which redirect to use when finally implementing it. Thanks. Oct 23, 2013 at 22:37

1 Answer 1

1

You could try this

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !installer_1\.0\.3\.zip 
RewriteRule ^/installer_(.*).zip$ http://www.example.com/download/installer_1.0.3.zip [R=301,L]
2
  • I think this might work but it's causing loop... Oct 23, 2013 at 20:58
  • Please, go ahead and try the edited version. It should stop the loop. You can try the condition without backslashes if that doesn't work.
    – Jompper
    Oct 23, 2013 at 21:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .