httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Norman Khine <>
Subject [users@httpd] block IP range with mod_rewrite
Date Tue, 17 Oct 2006 13:07:27 GMT
hello again,
i have the following rewrite rule,

<VirtualHost *:80>
  ServerName domain.tld
  ServerAlias www.domain.tld
  RewriteEngine On
  RewriteMap    hosts-deny  txt:/home/user/apache/hosts.deny
  RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
  RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
  RewriteRule   ^/.*  -  [F]
  RewriteRule ^/(.*)
  ErrorLog /var/log/apache2/domain.tld_error.log
  CustomLog /var/log/apache2/domain.tld_access.log combined
  RewriteLog /var/log/apache2/domain.tld_rewrite_log

where the

RewriteMap    hosts-deny  txt:/home/user/apache/hosts.deny

has the enries of the IP's I want to block from accessing my webserver.

This does not work as my second RewriteRule is not taken into account.
What is the best way to have this look at the IP address if it is in the
list to block it, if not then the go to the next RewriteRule?

When I run this the server did not respond, even though my IP was not in
the list.

Using the [F], does this mean the Rewrite Stops there and the second
Rule is not taken into account?

Many thanks


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message