The Human Element Blog

Creating sitemaps for Magento multistore instances

Posted Sep 17, 2015 by

Magento Sitemaps for Multistore Instances

This image is courtesy of the internet.

Sitemaps are an important part of every eCommerce website. They help search engines find and index your products and content. However, when creating a mutli-store site using Magento, if you’ve tried to setup multiple sitemap files, you’ve probably seen the message –

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

This odd error message comes from a small bug that forces Magento to only use a file named sitemap.xml to store the sitemap in. So if you have multiple stores and domains, all of the sites will use the same file and each will continually overwrite the sitemap with their own information.

This has the adverse affect of confusing 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.

Fortunately, there is an easy fix. You can create different directories for each domain to store the sitemap.xml files. This will require that you, or your developer, have access to the server to create folders and update files.

Note: Some of these actions require modifying files on your site. If you don’t have access or don’t feel comfortable doing it, please contact your developer or hosting company and they can easily make these updates.

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


  • 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.


  • 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.

Posted By

Chief Technology Officer

Comments (5)

Raul posted

Great post. I had some problems creating sitemaps in magento as it generated so not clear messages errors. And this post showed me the way to do it. Starting by creating the right folders in the home directory and assiging the writing privileges. Thanks for the info.

Joe posted

Hi, thanks for the great post, I'm having some problems, I have two domains, in my primary domain the sitemap redirects fine, my second domain redirects to a 404 error. I have it setup like this: primarydomain.com/sitemaps/pd-en/sitemap.xml (works fine), seconddomain.com/sitemaps/sd-en/sitemap.xml (404 error).

Francis Kim posted

Thanks for this Greg.

Mage Lover posted

Great ad useful tutoriaL. Well, during research I have also found a guide on Magento 2, may it will help others also: https://magenticians.com/setup-multi-store-in-magento-2/

Alex posted

Thanks Greg for sharing this post, i was looking for healp in creating multiple store in magento and your article helped me a lot, i figured out the issue with the help of your article and this one, https://www.cloudways.com/blog/multi-vendor-marketplace-magento-2/

Post a comment