> On Tue, Mar 17, 2009 at 12:44 PM, Anders Norrbring <lists@xxxxxxxxxxxx> > wrote: > >> 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?) > > > > > > Thanks! > > Would I not need a 'RewriteCond' to make this work? Only the rules? > > > RewriteCond applies a rewrite rule conditionally, so it shouldn't be > needed if you want to apply it to all requests. That doesn't mean all > requests will be rewritten of course, only the ones that match it. A > RewriteCond lets you condition on things beyond just the URL. Without > actually checking the doc, I /think/ you can use it to match against > Mime-Type like I hinted at above. This would be useful if you want to > match images that don't end in a normal image file extension, but it's > going to place additional load on your server because it would need to > go a subrequest for each request to see what the mime-type is. And > actually in your case, since there's no server back there to actually > check against, it won't do you any good. > > So short answer, "No, you don't need a RewriteCond for this to work." > > Cheers, > -Brian Wonderful! It works just as I wanted to. Thank you very much Brian. Anders. __________ Information from ESET NOD32 Antivirus, version of virus signature database 3944 (20090317) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com --------------------------------------------------------------------- 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