<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
+<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
+<!--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This file is generated from xml source: DO NOT EDIT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<body id="manual-page"><div id="page-header">
<p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.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.5</p>
-<img alt="" src="../images/feather.gif" /></div>
+<img alt="" src="../images/feather.png" /></div>
<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
<div id="path">
<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.5</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>When not to use mod_rewrite</h1>
<p>This document supplements the <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
<a href="../mod/mod_rewrite.html">reference documentation</a>. It describes
-perhaps one of the most important concepts about mod_rewrite - namely,
+perhaps one of the most important concepts about <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> - namely,
when to avoid using it.</p>
-<p>mod_rewrite should be considered a last resort, when other
+<p><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> should be considered a last resort, when other
alternatives are found wanting. Using it when there are simpler
alternatives leads to configurations which are confusing, fragile, and
hard to maintain. Understanding what other alternatives are available is
-a very important step towards mod_rewrite mastery.</p>
+a very important step towards <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> mastery.</p>
<p>Note that many of these examples won't work unchanged in your
particular server configuration, so it's important that you understand
<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><ul class="seealso"><li><a href="#comments_section">Comments</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><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>
<p>To redirect URLs under <code>/one</code> to
<code>http://one.example.com</code>, do the following:</p>
-<pre class="prettyprint lang-config">Redirect /one/ http://one.example.com/</pre>
+<pre class="prettyprint lang-config">Redirect "/one/" "http://one.example.com/"</pre>
+<p>To redirect one hostname to another, for example
+<code>example.com</code> to <code>www.example.com</code>, see the
+<a href="remapping.html#canonicalhost">Canonical Hostnames</a>
+recipe.</p>
+
<p>To redirect <code>http</code> URLs to <code>https</code>, do the
following:</p>
<pre class="prettyprint lang-config"><VirtualHost *:80>
ServerName www.example.com
- Redirect / https://www.example.com/
-</VirtualHost >
+ Redirect "/" "https://www.example.com/"
+</VirtualHost>
<VirtualHost *:443>
ServerName www.example.com
# ... SSL configuration goes here
-</VirtualHost ></pre>
+</VirtualHost></pre>
<p>The use of <code>RewriteRule</code> to perform this task may be
<p>The <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> directive
provides mapping from a URI to a directory - usually a directory outside
of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. Although it
-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>
+is possible to perform this mapping with <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>,
+<code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> is the preferred method, for
+reasons of simplicity and performance.</p>
-<div class="example"><h3>Using Alias</h3><pre class="prettyprint lang-config">Alias /cats /var/www/virtualhosts/felines/htdocs</pre>
+<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
+The use of <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> to perform this mapping may be
appropriate when you do not have access to the server configuration
files. Alias may only be used in server or virtualhost context, and not
in a <code>.htaccess</code> file.
<h2><a name="vhosts" id="vhosts">Virtual Hosting</a></h2>
<p>Although it is possible to handle <a href="vhosts.html">virtual hosts
with mod_rewrite</a>, it is seldom the right way. Creating individual
-<VirtualHost> blocks is almost always the right way to go. In the
+<code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code> blocks is
+almost always the right way to go. In the
event that you have an enormous number of virtual hosts, consider using
<code class="module"><a href="../mod/mod_vhost_alias.html">mod_vhost_alias</a></code> to create these hosts automatically.</p>
<div class="section">
<h2><a name="proxy" id="proxy">Simple Proxying</a></h2>
-<p><code>RewriteRule</code> provides the <a href="flags.html#flag_p">[P]</a> flag to pass rewritten URIs through
+<p><code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></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>
-<pre class="prettyprint lang-config">RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P]</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/?images(.*)" "http://imageserver.local/images$1" [P]</pre>
<p>However, in many cases, when there is no actual pattern matching
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>
-<pre class="prettyprint lang-config">ProxyPass /images/ http://imageserver.local/images/</pre>
+<pre class="prettyprint lang-config">ProxyPass "/images/" "http://imageserver.local/images/"</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>
-<pre class="prettyprint lang-config">ProxyPassReverse /images/ http://imageserver.local/images/</pre>
+<pre class="prettyprint lang-config">ProxyPassReverse "/images/" "http://imageserver.local/images/"</pre>
<p>You may need to use <code>RewriteRule</code> instead when there are
<code>example.com</code>. This can be done using the <code class="directive"><a href="../mod/core.html#if"><If></a></code> directive, as shown here:</p>
<pre class="prettyprint lang-config"><If "req('Host') != 'www.example.com'">
- Redirect / http://www.example.com/
+ Redirect "/" "http://www.example.com/"
</If></pre>
<p>See especially the <a href="../expr.html">expression evaluation
documentation</a> for a overview of what types of expressions you can
-use in <If> sections, and in certain other directives.</p>
+use in <code class="directive"><a href="../mod/core.html#if"><If></a></code> sections,
+and in certain other directives.</p>
</div></div>
<div class="bottomlang">
}
})(window, document);
//--><!]]></script></div><div id="footer">
-<p class="apache">Copyright 2015 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 2016 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/quickreference.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();