Any Apache RewriteRule Experts?

3 posts / 0 new
Last post
#1 Mon, 05/10/2010 - 08:10
PaliGap

Any Apache RewriteRule Experts?

I would like to redirect all requests that are NOT for a GIF file to the home page of another server.

I can do it so that if it IS a GIF request it works: RewriteEngine On RewriteRule ^(.*).gif$ http://anotherdomain.com/

But I can't figure out how to do the opposite - only redirect if it is NOT a GIF request! I thought it would be this: RewriteRule ^(.*)!.gif$ http://anotherdomain.com/

But that doesn't seem to work...

Mon, 05/10/2010 - 09:04
PaliGap

Ah...figured it out I think:

RewriteEngine on
RewriteCond %{REQUEST_URI} !\.gif$
RewriteRule .? http://anotherdomain.com/ [R=301,L]

Mon, 05/10/2010 - 09:08
andreychek

Glad you got it working -- thanks for the update!

-Eric

Topic locked