Epistolary
rob carlson . gallery . contact

deny from a referer

To deny or redirect visitors from a certain referer such as a page who links to your site in a context you seriously disapprove of, you can put the following .htaccess file in the root directory of your web page:

ErrorDocument 403 http://www.onlinesexaddict.org/
order mutual-failure
order deny,allow
SetEnvIf Referer "^http://.*example.com" local_ref=1
deny from env=local_ref

Dale Ghent adds:

If you're going the .htaccess file route (that is, putting the above config lines in a .htaccess file in your site's base directory) you need to make sure that the "AuthConfig" option to the "AllowOverride" directive is set.

For example, all my sites live under the "/local/vweb" directory on my server. So the document root for "yoursite.com" would be: /local/vweb/yoursite.com/htdocs"

So in my Apache httpd.conf file, I have the following:


    AllowOverride FileInfo AuthConfig Limit
    ...
    ... (other options)

The "AllowOverride" directive lets you specify what kind of Apache configration directives are allowed in a .htaccess file. The "AuthConfig" option is needed to specify authentication stuff in a .htaccess file.


No Comments | #2128

Leave a Reply

Please let me know how you got here, if this page was useful to you, and your opinions.

Unless noted, all content on epistolary.org is © Copyright 1999-2008 to Rob Carlson with all rights reserved. All information is verified when possible, cited as appropriate and applied in the real world at your own risk. Send all feedback to rob@vees.net.