summaryrefslogtreecommitdiff
path: root/docs/manual/rewrite/access.html.en
diff options
context:
space:
mode:
authorStefan Fritsch <sf@sfritsch.de>2014-03-29 21:56:19 +0100
committerStefan Fritsch <sf@sfritsch.de>2014-03-29 21:56:45 +0100
commit2a463b3cd73c32ee9dcd508248d0194923f435f4 (patch)
tree2ff478255a77a55031056790918b6f983bb7b20a /docs/manual/rewrite/access.html.en
parent86d5cc79d9d6750da8771fdb0c9ab22c19b8ad45 (diff)
downloadapache2-upstream/2.4.9.tar.gz
Imported Upstream version 2.4.9upstream/2.4.9
Diffstat (limited to 'docs/manual/rewrite/access.html.en')
-rw-r--r--docs/manual/rewrite/access.html.en58
1 files changed, 20 insertions, 38 deletions
diff --git a/docs/manual/rewrite/access.html.en b/docs/manual/rewrite/access.html.en
index df312e6e..17f9a602 100644
--- a/docs/manual/rewrite/access.html.en
+++ b/docs/manual/rewrite/access.html.en
@@ -9,7 +9,7 @@
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
-<script src="../style/scripts/prettify.js" type="text/javascript">
+<script src="../style/scripts/prettify.min.js" type="text/javascript">
</script>
<link href="../images/favicon.ico" rel="shortcut icon" /></head>
@@ -79,31 +79,25 @@ configuration.</div>
-<pre class="prettyprint lang-config">
-RewriteCond %{HTTP_REFERER} !^$
+<pre class="prettyprint lang-config">RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ - [F,NC]
-</pre>
+RewriteRule \.(gif|jpg|png)$ - [F,NC]</pre>
<p>In this second example, instead of failing the request, we display
an alternate image instead.</p>
-<pre class="prettyprint lang-config">
-RewriteCond %{HTTP_REFERER} !^$
+<pre class="prettyprint lang-config">RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ /images/go-away.png [R,NC]
-</pre>
+RewriteRule \.(gif|jpg|png)$ /images/go-away.png [R,NC]</pre>
<p>In the third example, we redirect the request to an image on some
other site.</p>
-<pre class="prettyprint lang-config">
-RewriteCond %{HTTP_REFERER} !^$
+<pre class="prettyprint lang-config">RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC]
-</pre>
+RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC]</pre>
<p>Of these techniques, the last two tend to be the most effective
@@ -119,12 +113,10 @@ RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC]
than redirecting that request elsewhere, this can be
accomplished without the use of mod_rewrite:</p>
- <pre class="prettyprint lang-config">
-SetEnvIf Referer example\.com localreferer
+ <pre class="prettyprint lang-config">SetEnvIf Referer example\.com localreferer
&lt;FilesMatch \.(jpg|png|gif)$&gt;
Require env localreferer
-&lt;/FilesMatch&gt;
- </pre>
+&lt;/FilesMatch&gt;</pre>
</dd>
</dl>
@@ -168,11 +160,9 @@ SetEnvIf Referer example\.com localreferer
range, if you are trying to block that user agent only from the
particular source.</p>
-<pre class="prettyprint lang-config">
-RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot
+<pre class="prettyprint lang-config">RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot
RewriteCond %{REMOTE_ADDR} =123\.45\.67\.[8-9]
-RewriteRule ^/secret/files/ - [F]
-</pre>
+RewriteRule ^/secret/files/ - [F]</pre>
</dd>
@@ -183,15 +173,13 @@ RewriteRule ^/secret/files/ - [F]
Rather than using mod_rewrite for this, you can accomplish the
same end using alternate means, as illustrated here:
</p>
- <pre class="prettyprint lang-config">
-SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway
+ <pre class="prettyprint lang-config">SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway
&lt;Location /secret/files&gt;
&lt;RequireAll&gt;
Require all granted
Require not env goaway
&lt;/RequireAll&gt;
-&lt;/Location&gt;
- </pre>
+&lt;/Location&gt;</pre>
<p>
As noted above, this technique is trivial to circumvent, by simply
@@ -222,13 +210,11 @@ SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway
<dt>Solution:</dt>
<dd>
-<pre class="prettyprint lang-config">
-RewriteEngine on
+<pre class="prettyprint lang-config">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>
+RewriteRule ^ - [F]</pre>
<div class="example"><p><code>
@@ -277,8 +263,7 @@ bsdti1.sdm.de -<br />
<p>The following ruleset uses a map file to associate each Referer
with a redirection target.</p>
-<pre class="prettyprint lang-config">
-RewriteMap deflector txt:/path/to/deflector.map
+<pre class="prettyprint lang-config">RewriteMap deflector txt:/path/to/deflector.map
RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}} =-
@@ -286,23 +271,20 @@ RewriteRule ^ %{HTTP_REFERER} [R,L]
RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
-RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]
-</pre>
+RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]</pre>
<p>The map file lists redirection targets for each referer, or, if
we just wish to redirect back to where they came from, a "-" is
placed in the map:</p>
-<pre class="prettyprint lang-config">
-##<br />
+<pre class="prettyprint lang-config">##<br />
## deflector.map<br />
##<br />
<br />
http://badguys.example.com/bad/index.html -<br />
http://badguys.example.com/bad/index2.html -<br />
-http://badguys.example.com/bad/index3.html http://somewhere.example.com/
-</pre>
+http://badguys.example.com/bad/index3.html http://somewhere.example.com/</pre>
</dd>
@@ -330,7 +312,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/access.html'
}
})(window, document);
//--><!]]></script></div><div id="footer">
-<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
+<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
prettyPrint();