It seems there can be a problem with both the non-www and the www. versions of a domain turning up in search engine listings - like the credit for links being split or the worst possibility being a duplication issue. It’s a precaution worth taking, there’s certainly no harm in it.

No way could it be made to work on some of my sites, so I contacted the hosting support people. I heard nothing back, and ended putting in the code in that I’d seen recommended at forums and that was working with sites on other servers. The automated way through the control panel apparently wasn’t working with that server configuration. A week later I heard from support telling me that it was working, closing the ticket.

This is what the mod_rewrite code in .htaccess looks like that works:

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

And yes, I have redirected pages to example.com - more than once. :-)

Comments

One Response to “Mod_rewrite redirection to www.”

  1. Tim on November 5th, 2005 11:53 am

    What can you use for windows based hosted sites (.asp)? Thanks

Leave a Reply

You must be logged in to post a comment.