Forum Moderators: phranque
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [L,R=301]
or
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
On one host they both seem to work, so which is better to use 'all the time'?
Thank you
[edited by: jdMorgan at 3:35 pm (utc) on April 20, 2008]
[edit reason] example.com [/edit]
In httpd.conf or conf.d:
RewriteEngine on
#
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule (.*) http://example.com$1 [R=301,L]
-or-
RewriteEngine on
#
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule [b]^/([/b].*)$ http://example.co[b]m/$[/b]1 [R=301,L]
RewriteEngine on
#
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule (.*) http://example.co[b]m/$[/b]1 [R=301,L]
RewriteEngine on
#
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule [b]^/?([/b].*)$ http://example.co[b]m/$[/b]1 [R=301,L]
I deleted the "RewriteBase /" directive, as it was specifying the default value and therefore was not useful in this context.
Jim