summaryrefslogtreecommitdiff
path: root/docs/manual/rewrite/avoid.html.en
diff options
context:
space:
mode:
Diffstat (limited to 'docs/manual/rewrite/avoid.html.en')
-rw-r--r--docs/manual/rewrite/avoid.html.en88
1 files changed, 57 insertions, 31 deletions
diff --git a/docs/manual/rewrite/avoid.html.en b/docs/manual/rewrite/avoid.html.en
index bfe4b3a0..1ef3f7c2 100644
--- a/docs/manual/rewrite/avoid.html.en
+++ b/docs/manual/rewrite/avoid.html.en
@@ -8,10 +8,13 @@
<title>When not to use mod_rewrite - Apache HTTP Server</title>
<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 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>
+
<link href="../images/favicon.ico" rel="shortcut icon" /></head>
<body id="manual-page"><div id="page-header">
-<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</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>
<p class="apache">Apache HTTP Server Version 2.4</p>
<img alt="" src="../images/feather.gif" /></div>
<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
@@ -53,7 +56,7 @@ files to work with, you may need to resort to
<li><img alt="" src="../images/down.gif" /> <a href="#vhosts">Virtual Hosting</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#proxy">Simple Proxying</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#setenv">Environment Variable Testing</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><li><a href="remapping.html">Redirection and remapping</a></li><li><a href="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li></ul></div>
+</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><li><a href="remapping.html">Redirection and remapping</a></li><li><a href="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="rewritemap.html">Using RewriteMap</a></li><li><a href="advanced.html">Advanced techniques</a></li></ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="redirect" id="redirect">Simple Redirection</a></h2>
@@ -81,25 +84,24 @@ and <code>/one/three/four.html</code>.</p>
<p>To redirect URLs under <code>/one</code> to
<code>http://one.example.com</code>, do the following:</p>
-<div class="example"><p><code>
-Redirect /one/ http://one.example.com/
-</code></p></div>
+<pre class="prettyprint lang-config">Redirect /one/ http://one.example.com/</pre>
+
<p>To redirect <code>http</code> URLs to <code>https</code>, do the
following:</p>
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
&lt;VirtualHost *:80&gt;
-ServerName www.example.com<br />
-Redirect / https://www.example.com/<br />
+ ServerName www.example.com
+ Redirect / https://www.example.com/
&lt;/VirtualHost &gt;
-<br />
+
&lt;VirtualHost *:443&gt;
-ServerName www.example.com<br />
-<br />
-# ... SSL configuration goes here<br />
+ ServerName www.example.com
+ # ... SSL configuration goes here
&lt;/VirtualHost &gt;
-</code></p></div>
+</pre>
+
<p>The use of <code>RewriteRule</code> to perform this task may be
appropriate if there are other <code>RewriteRule</code> directives in
@@ -123,9 +125,8 @@ is possible to perform this mapping with <code>mod_rewrite</code>,
<code>Alias</code> is the preferred method, for reasons of simplicity
and performance.</p>
-<div class="example"><h3>Using Alias</h3><p><code>
-Alias /cats /var/www/virtualhosts/felines/htdocs
-</code></p></div>
+<div class="example"><h3>Using Alias</h3><pre class="prettyprint lang-config">Alias /cats /var/www/virtualhosts/felines/htdocs</pre>
+</div>
<p>
The use of <code>mod_rewrite</code> to perform this mapping may be
@@ -165,25 +166,28 @@ seems like the right approach.</p>
<p><code>RewriteRule</code> provides the <a href="flags.html#flag_p">[P]</a> flag to pass rewritten URIs through
<code class="module"><a href="../mod/mod_proxy.html">mod_proxy</a></code>.</p>
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P]
-</code></p></div>
+</pre>
+
<p>However, in many cases, when there is no actual pattern matching
-meeded, as in the example shown above, the <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code> directive is a better choice.
+needed, as in the example shown above, the <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code> directive is a better choice.
The example here could be rendered as:</p>
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
ProxyPass /images/ http://imageserver.local/images/
-</code></p></div>
+</pre>
+
<p>Note that whether you use <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> or <code class="directive"><a href="../mod/mod_proxy.html#proxypass">ProxyPass</a></code>, you'll still need to use the
<code class="directive"><a href="../mod/mod_proxy.html#proxypassreverse">ProxyPassReverse</a></code> directive to
catch redirects issued from the back-end server:</p>
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
ProxyPassReverse /images/ http://imageserver.local/images/
-</code></p></div>
+</pre>
+
<p>You may need to use <code>RewriteRule</code> instead when there are
other <code>RewriteRule</code>s in effect in the same scope, as a
@@ -196,7 +200,7 @@ accomplish.</p>
<h2><a name="setenv" id="setenv">Environment Variable Testing</a></h2>
<p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> is frequently used to take a particular
-action based on the presence or absense of a particular environment
+action based on the presence or absence of a particular environment
variable or request header. This can be done more efficiently using the
<code class="directive"><a href="../mod/core.html#if">&lt;If&gt;</a></code>.</p>
@@ -205,11 +209,12 @@ variable or request header. This can be done more efficiently using the
hostname, such as <code>www.example.com</code> instead of
<code>example.com</code>. This can be done using the <code class="directive"><a href="../mod/core.html#if">&lt;If&gt;</a></code> directive, as shown here:</p>
-<div class="example"><p><code>
-&lt;If "$req{Host} != 'www.example.com'"&gt;<br />
-RedirectMatch (.*) http://www.example.com$1<br />
+<pre class="prettyprint lang-config">
+&lt;If "req('Host') != 'www.example.com'"&gt;
+ Redirect / http://www.example.com/
&lt;/If&gt;
-</code></p></div>
+</pre>
+
<p>This technique can be used to take actions based on any request
header, response header, or environment variable, replacing
@@ -223,7 +228,28 @@ use in &lt;If&gt; sections, and in certain other directives.</p>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/rewrite/avoid.html" title="English">&nbsp;en&nbsp;</a> |
<a href="../fr/rewrite/avoid.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
-</div><div id="footer">
+</div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
+<script type="text/javascript"><!--//--><![CDATA[//><!--
+var comments_shortname = 'httpd';
+var comments_identifier = 'http://httpd.apache.org/docs/2.4/rewrite/avoid.html';
+(function(w, d) {
+ if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
+ d.write('<div id="comments_thread"><\/div>');
+ var s = d.createElement('script');
+ s.type = 'text/javascript';
+ s.async = true;
+ s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
+ (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
+ }
+ else {
+ d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
+ }
+})(window, document);
+//--><!]]></script></div><div id="footer">
<p class="apache">Copyright 2012 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="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
+<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();
+}
+//--><!]]></script>
</body></html> \ No newline at end of file