Knowledgebase

How to block particular sites from accessing your site

If you don't want some sites to be able to link to pages on your site, you can prevent this by using a few Apache directives placed in the .htaccess file that's in the public_html directory of your hosting account.

If, for example, you don't want links to pages on your site that are put on the site domain.com to actually display the requested pages on your site, you can use the following directives:

SetEnvIf Referer domain\.com disable_links
Deny from env=disable_links

The SetEnvIf directive sets the environment variable disable_links (you can use another name) which will be applied when the Referer (the site containing the links) is domain.com. The above SetEnvIf directive is set in such a way so that it also includes subdomains of domain.com (e.g. subdomain.domain.com) and also pages within domain.com (e.g. domain.com/folder/example.html).

While the above directives will also disable the hotlinking of images for the specified site, you can prevent just the use of images from your site and accept links to pages on your site. It's done in a very similar way. For more information check out the article on preventing hotlinking.

Was this answer helpful?

 Print this Article

Also Read