I just did this yesterday for the same reasons as you. I got the code from my hosting service. It’s a little different from what you have:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
But that doesn’t mean you should use this without finding out for sure. I think I read that the code can be different for Apache servers and others. (If not, someone will let us know.)
After I got the file on the server, everything worked perfectly and all the other possibilities resolved to www.example.com
I found an easy way to get it on the server. In my control panel there’s a file management icon, of course. And in there I’m able to create a file right on the server, so I didn’t have to worry about using a text editor and uploading the file.
HTH
Martin
On Mar 18, 2011, at 8:22 PM, TeamSDA wrote:
Hi All,
Currently our site is allowing visitors to navigate to the home page using several url paths. I’ve contacted my hosting provider to get some suggestions on redirecting our site to www.example.com. They gave me a link to a forum post where there was the provided code below. I have a couple questions on creating a .htaccess file:
1 - Will the code below redirect all traffic to my home page to www.example.com (exactly)? Redirecting example.com and Example Domain?
2 - I will use the TextEdit.app to save a plain text file encoding using Unicode (UTF-8). Any issues with this?
3 - Is there any other code I need in the document to make it function properly as a .htaccess file?
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www.example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Thank you for your help,
TeamSDA_Christian
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options