.htaccess not blocking a specified referrer

ddantes used Ask the Experts™
I'm using .htaccess to block web visits from unwanted referrers.  However, I still get occasional visits, most recently from www.housesittersinternational.com   Can you explain how this is happening, and how to remedy it?

#Block traffic from "bad" referrers
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_REFERER} make-money-online\.7makemoneyonline\.com [NC,OR]
RewriteCond %{HTTP_REFERER} 245\.semalt\.com [NC,OR]
RewriteCond %{HTTP_REFERER} best-seo-solution\.com [NC,OR]
RewriteCond %{HTTP_REFERER} best-seo-offer\.com [NC,OR]
RewriteCond %{HTTP_REFERER} 100dollars-seo\.com [NC,OR] 
RewriteCond %{HTTP_REFERER} buttons-for-your-website\.com [NC,OR]
RewriteCond %{HTTP_REFERER} Get-Free-Traffic-Now\.com [NC,OR]
RewriteCond %{HTTP_REFERER} semalt\.com [NC,OR]
RewriteCond %{HTTP_REFERER} housesittersinternational\.com [NC,OR]
RewriteCond %{HTTP_REFERER} buttons-for-website\.com [NC,OR]
RewriteCond %{HTTP_REFERER} success-seo\.com [NC,OR]
RewriteCond %{HTTP_REFERER} semaltmedia\.com [NC]
RewriteRule .* - [F]

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017

Where is the .htaccess versus the pages being accessed?


Thank you for your question.  .htaccess resides in the root folder on the server, at the same level as the pages which were accessed.
Distinguished Expert 2017
You can add rewriteloglevel to see what is going on, the patter of the referer might be URL encoded, or something else caused it to not match.

Presumably, you have confirmed that your httpd.conf allows the rules within .htaccess to be handled/processed. allowOverride

Telnet localhost 80
GET http://www.yoursite.com HTTP/1.1
Host: yourhostname
Referer: one of the entries on your list

See what you get in response, based on your rule, you should get a Status: 403 in the HTTP response.
If you run this test when the loglevel and the log file define, you can see the processing and that may explain why the rule does not match when it should have.

Unfortunately, from the information you posted, there is nothing jumping out.  See when running the tests,  whether disabling the rewriteBase commenting it out,  makes a difference .


Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial