301 Redirects – How to Redirect Non-WWW to WWW

.htaccess

I have website where all links http://example.com/PRODUCTPAGE redirect to http://www.example.com

It´s always missing the path after the domain name in my case the productpage.

I know this is partly SEO wise but I´m wondering besides the SEO effect if changing this in my .htaccess would have any effect on other functionality from Magento?

If needed I can paste my .htacess but I have not changed anything really and I´m mostly wondering what would change.

Best Answer

I think this would work fine for you as of my understanding without having any issues regarding Magento:

1) Open the .htaccess file and locate the "RewriteEngine on" line and right after it add the following lines:

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

Once you do this, save the .htaccess file and log in to the Magento admin.

2) Go to the System > Configuration and from the left panel click the "Web" button.

Unfold the "Unsecured" set of options and change the "Base URL" option from http://example.com to http://www.example.com.

Save the changes and your Magento website will be running with www.example.com only!

Related Topic