]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Encourage people to use Redirect rather than mod_rewrite.
authorRich Bowen <rbowen@apache.org>
Tue, 9 Mar 2010 20:49:59 +0000 (20:49 +0000)
committerRich Bowen <rbowen@apache.org>
Tue, 9 Mar 2010 20:49:59 +0000 (20:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@921116 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/rewrite/remapping.html.en
docs/manual/rewrite/remapping.xml

index 8fb2b8a372dbf7c559bb36b2aa0c2f8953428749..a1cb9f3a281331ab324148bb84235ed2e868b94a 100644 (file)
@@ -269,6 +269,27 @@ RewriteRule ^(.*).html$ $1.php
         <dt>Solution:</dt>
 
         <dd>
+
+<p>The very best way to solve this doesn't involve mod_rewrite at all,
+but rather uses the <code class="directive"><a href="../mod/alias.html#redirect">Redirect</a></code>
+directive places in a virtual host for the non-canonical
+hostname(s).</p>
+
+<div class="example"><pre>
+&lt;VirtualHost *:80&gt;
+  ServerName undesired.example.com
+  ServerAlias example.com notthis.example.com
+
+  Redirect / http://www.example.com/
+&lt;/VirtualHost&gt;
+</pre></div>
+
+<p>However, there are situations where you'll need to use mod_rewrite -
+primarily when you don't have access to the main server configuration
+file, or if you wish to do this dynamically for a larger number of
+hostnames. For these situations, you might use one of the recipes
+below.</p>
+
 <p>For sites running on a port other than 80:</p>
 <div class="example"><pre>
 RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
index a392c83b699bcead4762a8eb505c51d400f8192d..bc4abf40e7b5cfdaad4dac28e54f6b90f046610f 100644 (file)
@@ -270,6 +270,27 @@ RewriteRule ^(.*).html$ $1.php
         <dt>Solution:</dt>
 
         <dd>
+
+<p>The very best way to solve this doesn't involve mod_rewrite at all,
+but rather uses the <directive module="alias">Redirect</directive>
+directive places in a virtual host for the non-canonical
+hostname(s).</p>
+
+<example><pre>
+&lt;VirtualHost *:80&gt;
+  ServerName undesired.example.com
+  ServerAlias example.com notthis.example.com
+
+  Redirect / http://www.example.com/
+&lt;/VirtualHost&gt;
+</pre></example>
+
+<p>However, there are situations where you'll need to use mod_rewrite -
+primarily when you don't have access to the main server configuration
+file, or if you wish to do this dynamically for a larger number of
+hostnames. For these situations, you might use one of the recipes
+below.</p>
+
 <p>For sites running on a port other than 80:</p>
 <example><pre>
 RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]