Forum Moderators: phranque
I am currently having problems blocking a website. I am using the excellent bad-bot script that uses the setenvif commands to give the big [F] to these nasty bots. I have been experimenting with including a line to block a domain but this doesn't work.
I have tried adding this line:
SetEnvIf Referer ^http://(www\.)?blockeddomain\.com getout
But when you click through to my site from the blocked domain it is still allowed and the forbidden page is not displayed.
I also wondered is there a way of blocking a website that resides at a subdirectory? For example you have these sites where people can sign up to free webspace and they are given [/www.somebigsite.com/mywebspace/...] (not sure if you can mention the name here - but the one I am thinking of was bought by Yahoo and begins with g ;))
I tried SetEnvIf Referer ^http://(www\.)?blockeddomain\.com/mywebspace/ getout
but this didn't work either. Consequently I can't ban by IP address as since it is a subdirectory it doesnt have one - or does it?
Can anyone help? Cheers!
SetEnvIf Referer "^http://(www\.)?blockeddomain\.com" getout
In other words, your code probably works.
Jim
<edit>Ah ha I found the problem - the firewall was removing referer information, so although the code was working, when I was testing, it didn't look like it was working.
Any idea how this can be applied to the subdirectory? As I have tried it on a url, but when you try to block a site based at subdir level (as described in #1) it doesn't work...</edit>
A referrer is a referrer, so there is no fundamental difference between a domain-level referer and a subdirectory-level referer. As far as your server is concerned, they are just strings to be matched.
Jim
SetEnvIfNoCase Referer red getout
or
SetEnvIf Referer red getout
You may also use ^ "beginnings" and $ "Ends"
these methods will work with the main domain, sub-domain or anything else the referrer regulary includes in the referring lines.
Some caution should be kept in mind with the use of this words as I'm sure you have no desire to exclude innocent visitors.