0

I'm switching servers and need to change the following RewriteCond & RewriteRule commands in the .htaccess file.
Right now I'm pointing domain.com to www.domain.com

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

I need to switch the commands and do the opposite where I point www.domain.com to domain.com.
I would appreciate some help with the syntax. Thank you

2
Contributors
3
Replies
10
Views
3 Years
Discussion Span
Last Post by Dani
0
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^(.*)$ http\:\/\/domain.com\/$1 [R=301,L]

Have you tried simply swapping out where the www is?

0

OK, I'll try this. Are you sure this is the right syntax.
I'd rather not experiment, since I'm following specific instructions from my host provider and at some point loose access to the VPS that I'm adding this code to.

Edited by techman41973

0

I might be wrong about escaping the http:// part. I removed the double quotes that you had b/c I had never seen that before. This should work:

RewriteCond     %{HTTP_HOST}    ^domain.com$                [NC] 
RewriteRule     ^(.*)$      http://www.domain.com/$1        [R=301,L] 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.