From: Rich Bowen Date: Tue, 9 Mar 2010 20:49:59 +0000 (+0000) Subject: Encourage people to use Redirect rather than mod_rewrite. X-Git-Tag: 2.3.6~384 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c1301a84ab208cc3247e9d20c3d060528c989ec;p=thirdparty%2Fapache%2Fhttpd.git Encourage people to use Redirect rather than mod_rewrite. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@921116 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/remapping.html.en b/docs/manual/rewrite/remapping.html.en index 8fb2b8a372d..a1cb9f3a281 100644 --- a/docs/manual/rewrite/remapping.html.en +++ b/docs/manual/rewrite/remapping.html.en @@ -269,6 +269,27 @@ RewriteRule ^(.*).html$ $1.php
Solution:
+ +

The very best way to solve this doesn't involve mod_rewrite at all, +but rather uses the Redirect +directive places in a virtual host for the non-canonical +hostname(s).

+ +
+<VirtualHost *:80>
+  ServerName undesired.example.com
+  ServerAlias example.com notthis.example.com
+
+  Redirect / http://www.example.com/
+</VirtualHost>
+
+ +

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.

+

For sites running on a port other than 80:

 RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
diff --git a/docs/manual/rewrite/remapping.xml b/docs/manual/rewrite/remapping.xml
index a392c83b699..bc4abf40e7b 100644
--- a/docs/manual/rewrite/remapping.xml
+++ b/docs/manual/rewrite/remapping.xml
@@ -270,6 +270,27 @@ RewriteRule ^(.*).html$ $1.php
         
Solution:
+ +

The very best way to solve this doesn't involve mod_rewrite at all, +but rather uses the Redirect +directive places in a virtual host for the non-canonical +hostname(s).

+ +
+<VirtualHost *:80>
+  ServerName undesired.example.com
+  ServerAlias example.com notthis.example.com
+
+  Redirect / http://www.example.com/
+</VirtualHost>
+
+ +

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.

+

For sites running on a port other than 80:

 RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]