Magento Basic Setting - Distinguish WWW from non-WWW domain structure

Distinguish WWW from non-WWW domain structure

Magento 2 is awesome, now you can learn and practice every thing about Magento 2 with

Magestore Ultimate Magento 2 Tutorial

More than 150 tips, guides and tutorial. Everything is Free forever.

50 000 Magento developers have joined, explore Magento 2 in the easiest way today!

Google and other search engines will often index your site two different ways: one with the www and another time with the non-WWW information.


If you haven`t set your preferred domain in Magento (as well as in Google Webmaster tools), you may be penalized for duplicate content. Or, inbound links from the non-WWW (more common with people linking from social media sites) may not be giving your main domain any real link juice, or inbound link results.


Another issue: if you have inbound links from Google CPC campaigns to the WWW domain, and your site`s navigation then changes to the non-WWW domain, you will often lose the tracking for Google`s conversion to purchase and Google Analytics.


Under “Unsecure” and “Secure” you can find the Base URL, where you can set the preferred domain. You can choose between the WWW and the non-WWW version of the URL. With changing the setting you don’t create a redirect from www to non-www or non-www to www but set only the preferred one.


Therefore it is a good idea to create a 301 redirect through .htaccess with mod_rewrite. Besides solving the WWW vs non-WWW problem this redirect prevents Magento from adding the SID query to your URLs.


Like ?SID=b9c95150f7f70d6e77ad070259afa15d. Make sure the Base URL is the same as redirect. When editing the.htaccess file you can add the following code to redirectindex.php to root.


Around line 119:


1  RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php HTTP/
2  RewriteRule ^index.php$ [R=301,L]


Or, when your Magento install is not in the root but in the sub-directory


1  RewriteBase /magento/ RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /magento/index.php  HTTP/
2  RewriteRule ^index.php$ [R=301,L]


Other Answers in the Category "Magento Basic Setting"