[thelist] Block a Referring URL

Brent Eades beades at almonte.com
Mon Mar 13 09:37:10 CST 2006


jono at charlestonwebsolutions.com wrote:

> Ordinarily, external incoming links are a good thing, but what about when
> it is not a good thing?  Is there a way to block a referring/incoming URL?
> 
> For example, www.company-one.com has a link to a particular page on
> www.company-two.com's Web site.  Can company-two.com block the incoming
> links that company-one has set up?


The following .htaccess should work, assuming the Apache server is 
configured to allow rewriting in the directory(s) in question:

   RewriteEngine on
   RewriteCond %{HTTP_REFERER} ^http://.*company-one.*$ [NC]
   RewriteRule  .* http://company-two.com/some_file.html [R]

This will redirect links from company-one.com (or other TLDs they may 
have, such as .net, etc) to a file of your choosing on company-two.com

If you don't want to redirect, change the third line to:

   RewriteRule .* - [F]

...which should produce a '403 Forbidden' result.

-- 
Brent Eades	
Almonte, Ontario
http://almonte.com




More information about the thelist mailing list