thinking-600x450

Ended Duplicate Content Issues Caused By Multiple Magento Home URLs

Share your love

In my Solution To The Magento 1 Default XML Sitemap Generator Problem post, I shared my discovery of a wrong homepage URL in Magento generated sitemaps. However, the solution in that post is only a prerequisite to how I completely ended duplicate content issues caused by multiple Magento home URLs. This post contains the last step.

The case of the hidden multiple homepage URLs

Editing the Magento system generated sitemap.xml file would be enough if the wrong homepage URL in the sitemap is a non-existing page. However, the page does exist. Additionally, I can add a trailing slash to it and the same page loads. But, if you don’t believe me, please test your Magento 1.0 site by visiting mydomain.com/home and mydomain.com/home/ (with trailing slash at the end of the URL). As you will see, you are not redirected to the base URL you have set in System => Configuration => Web. And, mydomain.com/home/ will not redirect to mydomain.com/home or vice versa.

The reason it needs optimization

I hope you are not confused by all these because it can get even more complicated. Hence, let me explain. Whether or not you’ve installed a premium template, as long as the active template uses “home” as the homepage’s CMS content block identifier in CMS => Pages then mydomain.com/home and mydomain.com/home/ will appear exactly the same as visiting mydomain.com. However, if the active template requires the homepage CMS content block identifier to be different from the default “home” identifier then mydomain.com/home and mydomain.com/home/ will remain accessible to everyone unless you disable the default “home” identifier CMS block.

I thought that if I disabled the default home CMS page block without doing what I did previously, Magento will automatically remove the /home from the sitemap it generates but it does not. Therefore, taking care of the issue by analyzing what goes on with the CMS page blocks doesn’t entirely solve the problem. I will still have to do a little programming and add two lines of 301 redirect codes in every Magento site’s root directory .htaccess file.

The needed htaccess codes

These two lines of 301 redirect codes prevent the /home and /home/ pages from causing any duplicate content or 404 error issues at the outset:


RewriteRule ^home/?$ http://www.mydomain.com/$1 [R=301,L]
RewriteRule ^home/$ http://www.mydomain.com/$1 [R=301,L]

So, I simply put these 2 lines of code after my non-www to www and index.php to base URL redirect codes.

Example for HTTP sites:


Options +FollowSymLinks
RewriteEngine on
RewriteBase /	

## Redirect non-www to www	
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule ^(.*)$ http:\/\/www\.mydomain\.com\/$1 [R=301,L]

## Redirect index.php
RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index\.php$ /$1 [R=301,L] 
	
RewriteRule ^home/?$ ://www.mydomain.com/$1 [R=301,L]
RewriteRule ^home/$ ://www.mydomain.com/$1 [R=301,L]

And, when I migrate a Magento site from HTTP to HTTPS I just convert all the http:// in the code to https://. Then, I insert 2 more codes to make the http to https permanent redirect happen.

For SSL secure (HTTPS) Magento stores:


Options +FollowSymLinks
RewriteEngine on
RewriteBase /	

## Redirect non-www to www	
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule ^(.*)$ https:\/\/www\.mydomain\.com\/$1 [R=301,L]

## Redirect index.php
RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index\.php$ /$1 [R=301,L] 
	
## Redirect http to https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https:\/\/www\.mydomain\.com/$1 [R=301,L]
	
RewriteRule ^home/?$ https://www.mydomain.com/$1 [R=301,L]
RewriteRule ^home/$ https://www.mydomain.com/$1 [R=301,L]

So, that concludes the topic about the time I found these important technical problems to solve involving multiple Magento homepage URLs. I hope you find this solution useful in your technical SEO work.

Thank you for reading and please subscribe to my blog to get updated of new posts as they happen.

Share your love

Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124