Forum Moderators: phranque

Message Too Old, No Replies

Lost my anti-leech mod_rewrite rule can you help?

         

Krugar

4:23 am on Jun 15, 2004 (gmt 0)

10+ Year Member



I recently switched server hosts and before I could backup things they cleaned the server. I had a mod_rewrite rule that blocked image hot linking with the exception of one directory. The one explicitly defined directory was able to host images without being blocked.

The good news is I was able to rewrite most of the rule set with the exception of allowing the one particular directory. Can someone help me figure out how to do that. I just can't remember it for the life of me.

Below is the code I have the blocks all images on my server and loads a bogus red x image. I just need to allow images in a specific directory to be able to be linked.

code:
RewriteEngine on
RewriteRule ^/redx.gif$ - [PT,L]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain1.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain2.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?12.34.567.89(/)?.*$ [NC]
RewriteRule .*\.(gif夸pg夸peg在mp妃pg妃peg屹ip圯xe地vi妃ov存wf)$ [myshost.com...] [R,NC]

[edited by: Krugar at 4:24 am (utc) on June 15, 2004]

jdMorgan

4:31 am on Jun 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Simplifying and adding thje allowed directory:

RewriteEngine on
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]
RewriteCond %{HTTP_REFERER} !^http://192\.168\.0\.89 [NC]
RewriteRule \.(gif夸pe?g在mp妃pe?g屹ip圯xe地vi妃ov存wf)$ /redx.gif [NC]

Jim

Krugar

3:54 pm on Jun 21, 2004 (gmt 0)

10+ Year Member



Thanks JD,
It worked perfectly except for the two typos, heh. I won't hold it against you. But next time... Well sir that will cost you $.02. See where helping someone can get you.

All kidding aside, thanks. That's what was missing.