How to block/redirect hosts and subdomains of a host using htaccess?

Posted by Sven on Server Fault See other posts from Server Fault or by Sven
Published on 2012-11-28T07:08:40Z Indexed on 2012/11/28 11:05 UTC
Read the original article Hit count: 253

Filed under:
|
|
|
|

I want to block several host-domains and their subdomains, as well as IP-Adresses using htaccess. So far I added to my .htaccess-file:

# block doamins and all subdomains
Deny from .example.org
# block domainrange: 1.2.3.[1-255]
Deny from 1.2.3.
# Block single IP
Deny from 2.3.4.5

but still I had problems with spam from e.g. server1.example.org. What is wrong with my script?

Is it also possible to redirect all requests from certain hosts/IPs to a document (say: info.html)?

© Server Fault or respective owner

Related posts about .htaccess

Related posts about redirect