Forum Moderators: phranque

Message Too Old, No Replies

If no subdomains, should I redirect

"www\.example\.com" to "(.*)\.example\.com"

         

twist

8:10 pm on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I have no plans on using subdomains, would it be better to just exclude anything before my domain name?

Go from this,

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^.*$ [example.com...] [R=permanent,L]

to this,

RewriteCond %{HTTP_HOST} ^.*\.example\.com$ [NC]
RewriteRule ^.*$ [example.com...] [R=permanent,L]

Will it hurt, help, or do the same thing?

jdMorgan

4:36 am on Apr 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Faster:

RewriteCond %{HTTP_HOST} ^[^.]+\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]

It also allows for port number appended to domain name, and correctly redirects to same page in new domain (The parentheses necessary to create the $1 back-reference were missing).

Jim