httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Mearns <>
Subject Re: [users@httpd] Tips for redirects
Date Mon, 16 Mar 2009 18:59:41 GMT
On Mon, Mar 16, 2009 at 2:15 PM, Anders Norrbring <> wrote:
> Hi all.
> I'm not really familiar with the redirects and regex's needed to use it, so I'd like
to get some hints..
> I have a web server serving a number of websites, and while it's down I'd like to have
some redirects set up on another machine.
> The setup I'm looking for is:
> 1. Redirect all image requests (gif, jpg and png) to a specific image URL.
> 2. Redirect all other calls to a specific html page.
> Ideas are gratefully welcome.
> Anders.


For images:
RewriteRule ^/.*\.(png|jpeg|jpg|gif|bmp)$ /address_of_your_image.png

For everything else:
RewriteRule ^/.*$ /down_time.html [L,R=302]

That should do it, I think. You can add any other image extensions you
might have to the list in the first one. You could probably do it by
mime type, as well, but you'll probably need to do a sub-request and
rewrite conditions.

I actually use something very similar to the first one for battling
hotlinking. I have a page on my site that describes it, and gives a
detailed walk through of the regular expressions if you want to learn

Hope that helps.


P.S., before someone else says something, the =302 probably isn't
needed on the R flags, because I think Apache uses 302 as the default.
But it might be a good idea anyway, just to make sure they don't end
up as 301's, because that's not what you want (this is a temporary
condition, right?)

Feel free to contact me using PGP Encryption:
Key Id: 0x3AA70848
Available from:

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message