Block company domain from apache website how?
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, apache, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :so I am running a site on apache. I want to block all visitors from domain *.xyz.com
I tried adding the following in .htaccess file:
<Files *>
order allow,deny
allow from all
deny from .*example.com.*
</Files>
this didnt work. Can anyone help?
Not really. A webserver does not directly know the domain of its users which they may not even have one, in fact.
It does know the referrer, if sent but that only can protect you from a link from a certain domain. They can easily spoofed too, so when used referral discrimination is more of a deterrent than protection. A person that types the URL directly though sends no referrer.
What the server must know is the IP the request is coming which is where it serves the response to. If you want to block people whose machines are within a certain domain, you must block them by IP. Even so, proxies and VPNs can add a relay which effectively changes the IP address of requests.
To block by IP you put in the .htaccess a statement like:
deny from 192.168.*.*
Or:
deny from 192.168.0.0/16
To do this you have to figure out the IP range for the company or domain you are trying to block. In a few cases that use some kind of gateway, it may be even just one IP address, in others there may be quite a few.
Comments
Post a Comment