</div>
<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#blocked-inline-images">Forbidding Image "Hotlinking"</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#blocking-of-robots">Blocking of Robots</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#host-deny">Denying Hosts in a Blacklist</a></li>
</ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
</dl>
- </div></div>
+ </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="host-deny" id="host-deny">Denying Hosts in a Blacklist</a></h2>
+
+
+
+ <dl>
+ <dt>Description:</dt>
+
+ <dd>
+ <p>We wish to maintain a blacklist of hosts, rather like
+ <code>hosts.deny</code>, and have those hosts blocked from
+ accessing our server.</p>
+ </dd>
+
+ <dt>Solution:</dt>
+
+ <dd>
+<div class="example"><pre>
+RewriteEngine on
+RewriteMap hosts-deny txt:/path/to/hosts.deny
+RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
+RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND
+RewriteRule ^ - [F]
+</pre></div>
+
+<div class="example"><pre>
+##
+## hosts.deny
+##
+## ATTENTION! This is a map, not a list, even when we treat it as such.
+## mod_rewrite parses it for key/value pairs, so at least a
+## dummy value "-" must be present for each entry.
+##
+
+193.102.180.41 -
+bsdti1.sdm.de -
+192.76.162.40 -
+</pre></div>
+ </dd>
+
+ <dt>Discussion:</dt>
+ <dd>
+ <p>
+ The second RewriteCond assumes that you have HostNameLookups turned
+ on, so that client IP addresses will be resolved. If that's not the
+ case, you should drop the second rule, and drop the
+ <code>[OR]</code> flag from the first RewriteCond.
+ </p>
+ </dd>
+ </dl>
+
+</div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/rewrite/access.html" title="English"> en </a></p>
</div><div id="footer">
</section>
+<section id="host-deny">
+
+ <title>Denying Hosts in a Blacklist</title>
+
+ <dl>
+ <dt>Description:</dt>
+
+ <dd>
+ <p>We wish to maintain a blacklist of hosts, rather like
+ <code>hosts.deny</code>, and have those hosts blocked from
+ accessing our server.</p>
+ </dd>
+
+ <dt>Solution:</dt>
+
+ <dd>
+<example><pre>
+RewriteEngine on
+RewriteMap hosts-deny txt:/path/to/hosts.deny
+RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
+RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND
+RewriteRule ^ - [F]
+</pre></example>
+
+<example><pre>
+##
+## hosts.deny
+##
+## ATTENTION! This is a map, not a list, even when we treat it as such.
+## mod_rewrite parses it for key/value pairs, so at least a
+## dummy value "-" must be present for each entry.
+##
+
+193.102.180.41 -
+bsdti1.sdm.de -
+192.76.162.40 -
+</pre></example>
+ </dd>
+
+ <dt>Discussion:</dt>
+ <dd>
+ <p>
+ The second RewriteCond assumes that you have HostNameLookups turned
+ on, so that client IP addresses will be resolved. If that's not the
+ case, you should drop the second rule, and drop the
+ <code>[OR]</code> flag from the first RewriteCond.
+ </p>
+ </dd>
+ </dl>
+
+</section>
+
</manualpage>
<li><img alt="" src="../images/down.gif" /> <a href="#on-the-fly-content">On-the-fly Content-Regeneration</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#autorefresh">Document With Autorefresh</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#mass-virtual-hosting">Mass Virtual Hosting</a></li>
-<li><img alt="" src="../images/down.gif" /> <a href="#host-deny">Host Deny</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#proxy-deny">Proxy Deny</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#special-authentication">Special Authentication Variant</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#referer-deflector">Referer-based Deflector</a></li>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
-<h2><a name="host-deny" id="host-deny">Host Deny</a></h2>
-
-
-
- <dl>
- <dt>Description:</dt>
-
- <dd>
- <p>How can we forbid a list of externally configured hosts
- from using our server?</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>For Apache >= 1.3b6:</p>
-
-<div class="example"><pre>
-RewriteEngine on
-RewriteMap hosts-deny txt:/path/to/hosts.deny
-RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
-RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
-RewriteRule ^/.* - [F]
-</pre></div>
-
- <p>For Apache <= 1.3b6:</p>
-
-<div class="example"><pre>
-RewriteEngine on
-RewriteMap hosts-deny txt:/path/to/hosts.deny
-RewriteRule ^/(.*)$ ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND}/$1
-RewriteRule !^NOT-FOUND/.* - [F]
-RewriteRule ^NOT-FOUND/(.*)$ ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND}/$1
-RewriteRule !^NOT-FOUND/.* - [F]
-RewriteRule ^NOT-FOUND/(.*)$ /$1
-</pre></div>
-
-<div class="example"><pre>
-##
-## hosts.deny
-##
-## ATTENTION! This is a map, not a list, even when we treat it as such.
-## mod_rewrite parses it for key/value pairs, so at least a
-## dummy value "-" must be present for each entry.
-##
-
-193.102.180.41 -
-bsdti1.sdm.de -
-192.76.162.40 -
-</pre></div>
- </dd>
- </dl>
-
- </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
-<div class="section">
<h2><a name="proxy-deny" id="proxy-deny">Proxy Deny</a></h2>
</section>
- <section id="host-deny">
-
- <title>Host Deny</title>
-
- <dl>
- <dt>Description:</dt>
-
- <dd>
- <p>How can we forbid a list of externally configured hosts
- from using our server?</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>For Apache >= 1.3b6:</p>
-
-<example><pre>
-RewriteEngine on
-RewriteMap hosts-deny txt:/path/to/hosts.deny
-RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
-RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
-RewriteRule ^/.* - [F]
-</pre></example>
-
- <p>For Apache <= 1.3b6:</p>
-
-<example><pre>
-RewriteEngine on
-RewriteMap hosts-deny txt:/path/to/hosts.deny
-RewriteRule ^/(.*)$ ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND}/$1
-RewriteRule !^NOT-FOUND/.* - [F]
-RewriteRule ^NOT-FOUND/(.*)$ ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND}/$1
-RewriteRule !^NOT-FOUND/.* - [F]
-RewriteRule ^NOT-FOUND/(.*)$ /$1
-</pre></example>
-
-<example><pre>
-##
-## hosts.deny
-##
-## ATTENTION! This is a map, not a list, even when we treat it as such.
-## mod_rewrite parses it for key/value pairs, so at least a
-## dummy value "-" must be present for each entry.
-##
-
-193.102.180.41 -
-bsdti1.sdm.de -
-192.76.162.40 -
-</pre></example>
- </dd>
- </dl>
-
- </section>
-
<section id="proxy-deny">
<title>Proxy Deny</title>