Forum Moderators: phranque
RewriteEngine on
RewriteLog /var/log/httpd/rewrite.log
RewriteLogLevel 3
RwriteCond %{REQUEST_URI}!^/redx\.gif$
RwriteCond %{REQUEST_URI}!^/allowed_directory/
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain1\.com [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain2\.com [NC]
RewriteRule \.(gif¦jpe?g¦bmp¦mpe?g¦zip¦exe¦avi¦mov¦swf)$ /redx.gif [NC]
Please describe how it is not working; Does it not rewrite the request, or does it cause your server to catch fire?
What is in your error log and rewrite log when it doesn't work?
Is this code on the same server as before?
Has anything else about the server configuration been changed?
The only major problem I see is that you redirect blank referrers, which means your site "won't work" for a lot of users behind caching proxies, such as AOL, some other ISPs, and corporate networks.
Make sure you have included "FollowSymLinks" in your Options directive in httpd.conf. Otherwise, you'll need to add Options +FollowSymLinks to your code above, and possibly set AllowOverride Options in httpd.conf to allow you to do that.
Posting code on this forum changes pipe characters to broken "¦" pipes and also deletes the space between "}" and "!" in the code above. I assume you know this, but am posting this for others who may view this thread.
Jim
Therefore, have you flushed your browser and proxy cache after each change to these access policies?
Please confirm that you have checked the other configuration settings I mentioned above.
It is either a caching issue, a configuration change, or the code is not located where it should be -- mod_rewrite won't "quit" for no reason.
Jim