Forum Moderators: phranque

Message Too Old, No Replies

For some reason, this isn't working as intended.

My rewrite-fu has become weak.

         

Tristor

9:11 am on Jul 30, 2005 (gmt 0)

10+ Year Member



I am mirroring content for an online community I am involved in but I have encountered some leechers recently. I would like all requests with a referrer matching the leecher's site to be redirected to the wikipedia page on bandwidth theft. Unfortunately, when applying the following rule (and a bunch of other rules I have tried) it redirects requests from any referrer to the wikipedia page. I am sure you are all really tired of the requests for help with mod_rewrite by now, but even with my medium level of rewrite-fu I am unable to figure this one out. AFAICT, I have done everything correctly here.


RewriteEngine on
RewriteCond %{HTTP_REFERER} ^deadflesh$ [NC,OR]
RewriteRule ^.*$ http://en.wikipedia.org/wiki/Bandwidth_theft [R,L]

Any ideas? Prompt reply would be extra helpful due to the rate that the leechers are sucking my bandwidth with illegitimate traffic.

Longhaired Genius

9:20 am on Jul 30, 2005 (gmt 0)

10+ Year Member



Remove the ^ and $ from your fragment of referrer string (to make sure you get a match).

Remove the OR (you've got only one condition).

Let us know if that works.

Weelcome to Webmaster World.

Tristor

9:54 am on Jul 30, 2005 (gmt 0)

10+ Year Member



That worked, thanks. I can't believe I screwed up something so simple, I chock it up to it being after 2AM when I started on this (it is 5AM now) and not having slept for 3 days.

jdMorgan

4:31 pm on Jul 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The bad news is, you've transferred the problem (the loss of bandwidth) to your friends at wikipedia, essentially becoming a part of the problem yourself.

How about a nice, simple "Access Denied"?


ErrorDocument 403 /your_custom_403_page.html
RewriteEngine on
RewriteCond %{HTTP_REFERER} hotlinker_referrer_URL [NC]
RewriteRule !^your_custom_403_page\.html$ - [F]

Keeping your custom 403 page short will minimize loss of bandwidth to the hotlinkers.

Jim

Tristor

9:30 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



Good Idea, I think I'm going to cut and paste the linking section from Wikipedia into a special page locally and redirect them there. At the moment though, I am having larger issues. What I have above only blocks those that I choose too block individually, but it doesn't scale well. I need to come up with some sort of anti-hotlinking rules that won't block requests from places I want to get it. Perhaps you can assist me further. I now have the following:


RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mysite\.org [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.com\.com [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?anothersite\.com [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?andanother.name [NC]
RewriteRule \.(avi¦wmv¦mov)$ http://mirror.mysite.org/thieves/bandwidththeft.html [R,NC]

This doesn't work as intended, however. It blocks requests from everywhere.

[edited by: jdMorgan at 10:48 pm (utc) on July 31, 2005]
[edit reason] Removed specifics per TOS [/edit]

Tristor

10:30 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



I changed it as suggested, and now just redirect to my 403 page. I just added a snippet on my 403 page to say something about it.