Top Hosting Forum

WebHosting Reviews Forum


How to block traffic/visitors from certain domain/referer

Website Development is a general forum for Website Development related issues including questions on codes such as PHP, HTML and Javascript
Hosting Forum Description
Website Development is a general forum for Website Development related issues including questions on codes such as PHP, HTML and Javascript

How to block traffic/visitors from certain domain/referer

Postby hostingforum » Wed Jul 25, 2012 4:55 pm

Hi there, i have an Adsense website and it somehow gets traffic from adsense unfriendly sources. So i decided to use .htaccess file in my website directory to disallow these domains. These referers. So the people who visit my Adsense site from these domains will see only Forbidden message and no website.

How to block certain referrers?

Go to your webhosting FTP and in directory where is index.php or index.html add file .htaccess if it is not there already. the dot before filename is important to be present.

Edit htaccess file in Notepad or other editor and paste this:

banning single domain and all subpages:

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} banneddomain\.com [NC]
RewriteRule .* - [F]


banning multiple refering domains and their subpages:

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} banneddomain1\.com [NC,OR]
RewriteCond %{HTTP_REFERER} banneddomain2\.com
RewriteRule .* - [F]

Does it help? Any other ideas?



hostingforum
Site Admin
 
Posts: 671
Joined: Fri May 20, 2011 7:58 pm

Return to General Website Development & Programming

Who is online

Users browsing this forum: No registered users and 0 guests

.