Web Hosting Talk







View Full Version : Deny access from a referer


MrN
03-11-2002, 07:08 AM
Hello,
can someone tell me how I can deny the access from one referer with mod_rewrite?

Thank you

allan
03-11-2002, 10:12 AM
Originally posted by MrN
Hello,
can someone tell me how I can deny the access from one referer with mod_rewrite?


Depends on what you mean by "deny access". AFAIK mod_rewrite cannot be used to block access to someone, however, you can use mod_rewrite to redirect someone coming from a certain site to a different location. Say you wanted to direct all visitors from Web Hosting Talk to a special wht.html file, the syntax in your httpd.conf file would look something like this:


RewriteCond %{HTTP_REFERER} ^http://www.webostingtalk.com/*
RewriteRule ^/$ /some_dir/wht.html

karbon14
03-11-2002, 07:16 PM
Actually you can deny access from a certain referrer.
Here is what we added to an .htaccess file to block sites
from linking to images stored on our website


RewriteEngine on
RewriteCond %{HTTP_REFERER} .^*blackplanet.*$ [OR]
RewriteCond %{HTTP_REFERER} .^*migente.*$ [OR]
RewriteCond %{HTTP_REFERER} .^*beepworld3.*$ [OR]
RewriteCond %{HTTP_REFERER} .^*asianavenue.*$
RewriteRule \.(gif|jpg|GIF|JPG|jpeg)$ - [F]