Forum Moderators: coopster & phranque

Message Too Old, No Replies

How block a site from linking to my site

How block a site from linking to my site

         

StopSpam

8:22 pm on May 15, 2003 (gmt 0)

10+ Year Member



How can i avoid that certain sites i dont like ..
that they can not linktomy website ...

i know i can ban ip's from access to mysite but can i alsouse .htaccess file to block few domain names fromlinking to few of my pages

i try this but wont work....

order allow,deny
allow from all
deny from .guestbook.com 341.19.343.11
deny from env=ban

first domain then ip of site

im doing something wrong but i dotn know what

jdMorgan

8:43 pm on May 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



StopSpam,

How you do this depends on what you mean by the remote site "linking to your pages."

If they are including your pages inside iFrames on their site, then you will need to use Remote_Addr or Remote_Host. If they are simply including a link to your site on their site, then you only need to use Referer. Note that Referer is and must be misspelled, because that's how it was originally coded. Also note that using Remote_Host can have a big performance impact on your server - Use it only if absolutely necessary. Blocking by Referer, by IP address or by IP address range is much more efficient.

The following code will do it all, but it's probably not necessary - you can delete the lines you don't need.


SetEnvIf Referer ^http://.*\guestbook\.com ban
SetEnvIf Remote_Addr ^341\.19\.343\.11$ ban
SetEnvIf Remote_Host guestbook\.com ban
<Files *>
order deny,allow
deny from env=ban
</Files>

HTH,
Jim

StopSpam

9:26 pm on May 15, 2003 (gmt 0)

10+ Year Member



Hi JD ..

thanks for your reply ...

its like this: If they are simply including a link to your site on their site, then you only need to use Referer.

so i would need:

SetEnvIf Referer ^http://.*\guestbook\.com ban
<Files *>
order deny,allow
deny from env=ban
</Files>

and then the site can not have text links in a html page to my site .. what errror will they get if they click a link?
can i forward themto a diff domain or page , html?

and using refer is not giving server slow downs right?

jdMorgan

9:54 pm on May 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



StopSpam,

> its like this: If they are simply including a link to your site on their site, then you only need to use Referer.

Yes. And your code is correct.

> and then the site can not have text links in a html page to my site.

They can have a link, but it won't work as long as the user's browser provides a referer.

> what errror will they get if they click a link?

403-Forbidden, either your server's default Forbidden page, or a custom page if you have defined one.

> can i forward them to a diff domain or page , html?

Yes, using mod_rewrite, you can forward them to a special page, or anywhere else. Do a site search for "hotlinking" and "image blocking" - terms like that. There are a ton of threads on blocking/redirecting with mod_rewrite.

You can forward an image link to an image file, and an html link to an html file - I don't recommend trying to do it any other way, because it usually won't work.

> and using refer is not giving server slow downs right?

No, only Remote_Host is a problem. This is because it requires a reverse-DNS lookup. So, your server must issue a request for that reverse DNS info and wait for it to be supplied, before the request can be served.

HTH,
Jim

StopSpam

10:29 pm on May 15, 2003 (gmt 0)

10+ Year Member



Thanks for all Jim

;)