live chat software for live support and live help Online chat software for website

Live chat software

Browser based operator console
Articles

Webtools > Web design tools > Using .htaccess to block referrer spam

Using .htaccess to block referrer spam

Lately referrer spam became a great annoyance for the webmasters. If you are not sure what referrer spam is you may wish to check this article: http://www.spywareinfo.com/articles/referer_spam/

To block these spam referrers you need the following lines in your .htaccess file:

# set the spam_ref variableSetEnvIfNoCase Referer "^http://(www.)?some-spammer.com" spam_ref=1SetEnvIfNoCase Referer "^http://(www.)?other-spammer.com" spam_ref=1SetEnvIfNoCase Referer "^casino-poker" spam_ref=1# block all referres that have spam_ref set<FilesMatch "(.*)">Order Allow,DenyAllow from allDeny from env=spam_ref</FilesMatch>The first lines “setenvifnocase” assign a span_ref environment variable. Then we deny all access to such referrers in the FilesMatch clause.

You can also use wildcards with the above .htaccess directives to match a variety of hosts. For example, you can use

SetEnvIfNoCase Referer "*some_word*" spam_ref=1to match all referrers that contain the word 'some_word'.

For example you can ban visits from referral sites that contain in their domains words like: phentermine, viagra, cialis, shemale, porn, nude, celebrity, etc.

 

Tag : SPAM, referrer spam

 

WebTools Categories

Network Tools

Search engine tools

Web site tools

PHP resources

ASP tools and resources

Web design tools

JavaScript tutorials

CSS tutorials

Linux resources

Windows Resources

eCommerce Tools

Free Web Templates

MySql Resources

 

Popular Web Tools

MX lookup
WHOIS lookup
PTR Checker
IP Block Cheacker
IP to Location
Port Checker
Word Count
Character Count
XML sitemap creator
Age Calculator
Google Page rank
w3c validator