Forum Moderators: phranque
Was wondering how that site somehow got around the blocking and also if the domain block code listed last would work, and if any modifications are needed to either one so I can again block example.com and also www.example.com Also, why does one use followsymlinks but not the other? What does that line do anyway? Thanks.
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www.)?example.com.*$ [NC]
RewriteRule .(gif¦jpg)$ - [F]
--------------
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} example\.com
RewriteCond %{HTTP_REFERER} www.example\.com
RewriteRule .* - [F]
The second code snippet won't work, because it requires the referrer to be two different values simultaneously -- RewriteConds are logically ANDed in the absense of the optional [OR] flag.
A better way to code those RewriteConds would be the single line:
RewriteCond %{HTTP_REFERER} ^(www\.)?example\.com Options +FollowSymLinks is required, either in httpd.conf or in .htaccess, to enable mod_rewrite. If it makes no difference in your .htaccess testing, then it has already been set in httpd.conf.
Other than that, you can use either code snippet; The first blocks all referring doamins except your own from requesting images, while the second blocks the specific unwanted referring domain completely. So, either will block the undesired domain referrers, but only if the client sends a referrer header. You'll need to look at your raw logs to determine if requests are succeeding because the referrer is blank.
Jim
Emailed the German firm many times to turn-off the free cron job but my emails were mostly ignored. All of Feb and March my previously posted (first one) code successfully blocked it. But suddenly last week they seem to have somehow figured out how to get around it and the heavy traffic started once again.
Per Jim's suggestion earlier today I put this in my new htaccess file:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^(www\.)?example\.de
RewriteRule .(gif¦jpg)$ - [F]
However, it's not working as the high traffic continues with ongoing visits to the site every minute or so since implementing Jim's new code. Is the above code valid? I assume for the domain name to show-up in in the stats hosts log it must be sending referring headers, right?
Any other suggestions what to do as this is getting very troubling and also causing an extra bandwidth load on my server?
What is your server's response -- 200-OK or 403-Forbidden?
The desired result is a 403-Forbidden. However, these requests will still appear in your raw access log file, and in your 'stats', unless they are from a host IP address blocked at the firewall.
You may need to add
Options +FollowSymLinks Jim
My Bad. Thanks Again jdMorgan.