Creating multistore sitemaps in Magento

View Points

Blogs are our expert discrete, informal diary-style views. Our developers, designers, marketing personnel have got immense experience and would love to share their views with you.

Creating multistore sitemaps in Magento

Site maps are very crucial for an ecommerce store. A sitemap can improve how well your store is reviewed by search engines and how visible each page of the store is when related keywords are keyed in. However, while trying to create multiple site map files for multistore in Magento, you may have come across the message;

“filename.xml is not available and cannot be used.”

This occurs due to small problem that forces Magento to only use a file named sitemap.xml to store the sitemap in. Suppose you have three domains, store1.com, store2.com and store3.com and among these store1.com was your first Magento website. The problem is that Magento uses the .htaccess file to redirect different domains to the correct website within Magento. So, using shop2.com/sitemap.xml will return the sitemap of shop1.com, since this was the first website that you set up within Magento.

This confuses the search engine spiders, because regardless of which of your domains it’s trying to index, the content of the sitemap file will contain only the information for whichever domain the sitemap generator indexed most recently.

However you can fix this problem by creating different directories for each domain to store the sitemap.xml files. For this you or your developer need to have access to the server to update files by creating folders.

    • First, create a new folder called sitemaps in the root of your website, then create subfolders for each domain.

/sitemaps/domain_1/
/sitemaps/domain_2/

    • Then login to the Magento admin and navigate to –

catatlog -> google sitemap

    • Create or edit the sitemap listings for each store and set the “path to sitemap” field to be the path you created for the store.

/sitemaps/domain_1/
/sitemaps/domain_2/

    • Update your robots.txt file. To make sure that the search engine spiders are properly directed to the new sitemaps. You may need to update or create the robots.txt file. Edit the robots.txt file and add the following lines at the top —

# Website Sitemap

Sitemap: http://www.domain_1.com/sitemaps/domain_1/sitemap.xml
Sitemap: http://www.domain_2.com/sitemaps/domain_2/sitemap.xml

    • Finally, if your site uses the Apache web server engine, you should update the .htaccess file in the root of your website to direct any other sitemap requests to the proper place.

      Locate the following line below the line that reads —

RewriteEngine on

    • And add the following redirect statements below it —

#Sitemap: http://www.domain_1.com/sitemaps/domain_1/sitemap.xml
RewriteCond %{HTTP_HOST} ^.*domain_1\.com$
RewriteRule ^sitemap.xml$ sitemaps/domain_1/sitemap.xml [NC,L,R=301]

#Sitemap: http://www.domain_2.com/sitemaps/domain_2/sitemap.xml
RewriteCond %{HTTP_HOST} ^.*domain_2\.com$
RewriteRule ^sitemap.xml$ sitemaps/domain_2/sitemap.xml [NC,L,R=301]

And that’s it. Make sure to regenerate the sitemaps for all your stores and then try to view them in the browser. You can test the .htaccess redirects by navigating in your browser to http://www.domain_1.com/sitemap.xml and http://www.domain_2.com/sitemap.xml to make sure that the links actually go to the correct sites.

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*