Forum Moderators: phranque
Options +FollowSymlinks
RewriteEngine On
# Redirect all non-canonical domain requests to requested resource in canonical domain
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/ [R=301,L]
I can tell you that, with the code you supplied a request for the non-www version of ANY URL on your site will be redirected to the homepage which is not what you want.
You want to redirect the request of a non-www URL to the www version of that URL. I've included the updated rewrite for that below.
rewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]