Re: Tips for redirects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 16, 2009 at 2:15 PM, Anders Norrbring <lists@xxxxxxxxxxxx> 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.

Anders-

For images:
RewriteRule ^/.*\.(png|jpeg|jpg|gif|bmp)$ /address_of_your_image.png
[L,NC,R=302]

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
more: https://brianpmearns.com/bpm/shanghai

Hope that helps.

-Brian

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: http://pgp.mit.edu/

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux