.htaccess

They have: 3 posts

Joined: Sep 2001

I need to restrict access to a website, by allowing all access except for a particular referrer. One of my sites is linked to by an offensive site and we'd like to make sure the visitors to that site can't click through to ours.

For example, this code in an .htaccess file:

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Deny Joanne"
AuthType Basic

order allow,deny
allow from all
deny from .net-werkz.com
deny from 216.103.133.181

doesn't block the click throughs, because that is not the hostname. We don't want to deny all the sites at that host, just the net-werkz one.

Any ideas?

TIA

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

you wouldn't want to block IPs, you'd want to block HTTP-REFERRERs

They have: 3 posts

Joined: Sep 2001

Can I do that in the .htaccess file, and if so, how?

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

http://httpd.apache.org/docs-2.0/mod/mod_access.html

Also, my biggest mistake -- it's HTTP-REFERER. Sorry about that.

Anyway, you'll have to figure it out from there unless someone else can help, I'm far into Pure Theoretical for me. Wink

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

I think that you are going to have to do it through mod_rewrite. I haven't really tested this so I am not sure if it works. This goes in your htaccess file.

<?php
RewriteEngine on
RewriteCond
%{HTTP_REFERER} ^216.103.133.181$[OR]
RewriteCond %{HTTP_REFERER} ^net-werkz.com$
RewriteCond %{REQUEST_URI} !^/denied.html$
RewriteRule ^/.* /denied.html
?>

Then make a page denied.html that says something like the site is temporarily down so as not to anger anyone into thinking that you are blocking them.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.