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.*.*
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.