How can I fix my non-www to www url

I am trying to fixing the non-www to www url. My site is on Magento. Anybody knows how can I fix my non-www to www url.


Also be sure to check your Magento configuration.

Logged on to admin -> System Configuration -> Web

Check Unsecure and Secure paths


try adding this to your httpd.conf file on the server or the .htaccess file
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\.(.)$ [NC]
RewriteRule ^(.
)$ http://www.%{HTTP_HOST}$1 [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.)$ [NC]
RewriteRule ^(.
)$ https://www.%{HTTP_HOST}$1 [R=301,L]