Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite that used to work

         

Krugar

3:34 pm on Oct 20, 2004 (gmt 0)

10+ Year Member



I need some assitance in troubleshooting a problem. I used to use the following code to block hot linking of files on my site and returning a red X image if the referrer was not legit. However, it no longer seems to be working. I'm wondering if I am not using the correct code as I cannot be sure the file I am looking at for refference was the most up to date. Does anyone see any problems with the below code?

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]

jdMorgan

6:00 pm on Oct 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> However, it no longer seems to be working.

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

Krugar

6:18 pm on Oct 20, 2004 (gmt 0)

10+ Year Member



My apologies. It does no longer rewrites the request. It is the same server that it was on before. I stopped using it and now find the need to use it again. Nothing has changed as far as the server goes. Nothing has been updated or reconfigured or recompiled. I am the only one with access to it to make these sorts of changes. I've double checked the httpd.conf file and it is all the same as it was before. mod_rewrite is being loaded. The rewrite log is empty so maybe I need to increase my logging level. Hrmmm... Thanks for helping me brain storm JD.

jdMorgan

6:44 pm on Oct 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do these image/media requests show in your raw logs? Cached requests will not appear, and since they don't access your serrver, cannot be affected by your server policies.

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