Forum Moderators: phranque
I'm experiencing a moderate referrer spam problem, and while it's not a major bandwidth issue (currently), it's annoying me enough that I want to stop as much as I can. I've read several different ways to use .htaccess and Apache's RewriteEngine to accomplish, but I've only succeeded in completely blocking access to the site in question. (I got it back by removing the RewriteRule, but I can't seem to make a RewriteRule that blocks what I want it to.)
I suspect this is just a syntax issue or something, but I just can't make it work. Can someone take a look at the following and tell me why it might give every access attempt a 403?
RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://(www\.)?my-site\.org/ [NC]
RewriteCond %{HTTP_REFERER}!google\. [NC]
RewriteCond %{HTTP_REFERER}!^$
RewriteRule \.(jpe?g¦gif¦bmp¦png)$ images/nohotlink.jpg [L]
RewriteCond %{HTTP_REFERER} (keywords) [NC,OR]
RewriteRule .* - [F,L]
The first part is a thing to prevent hotlinking, but I included it in case it's throwing off the second set of rules.
Thanks.
At any rate, I'm mainly frustrated with myself that this Rewrite thing should be working but isn't for some reason.
# Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?example.com.*$ [OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?example.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?example.com*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?example.com.*$ [NC]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?example.com*$ [NC]
RewriteRule .* - [F,L]
thanks...hope to hear from you
[edited by: engine at 9:28 am (utc) on Mar. 22, 2005]
[edited by: jdMorgan at 1:01 am (utc) on Mar. 23, 2005]
[edit reason] examplified [/edit]
The code you posted won't work unless you add the [OR] -- or [NC,OR] -- flag to all but the last RewriteCond.
Jim