We have 2 domains: www.website.com and www.website.ca
Both websites are using the same root folder on the same Magento instance. What is the best way to create sitemaps for each site that use the same directory?
We have 2 domains: www.website.com and www.website.ca
Both websites are using the same root folder on the same Magento instance. What is the best way to create sitemaps for each site that use the same directory?
First, create a new folder called sitemaps in the root of your website, then create subfolders for each domain.
/sitemaps/domain1/
/sitemaps/domain2/
Then login to the Magento admin > Marketing > Site map
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/domain1/
/sitemaps/domain2/
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.domain1.com/sitemaps/domain1/sitemap.xml
Sitemap: http://www.domain2.com/sitemaps/domain2/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
You need to rewrites in .htaccess
And add the following redirect statements:
Sitemap: http://www.domain1.com/sitemaps/domain1/sitemap.xml
RewriteCond %{HTTP_HOST} ^.*domain1\.com$
RewriteRule ^sitemap.xml$ sitemaps/domain1/sitemap.xml [NC,L,R=301]
# Sitemap: http://www.domain2.com/sitemaps/domain2/sitemap.xml
RewriteCond %{HTTP_HOST} ^.*domain2\.com$
RewriteRule ^sitemap.xml$ sitemaps/domain2/sitemap.xml [NC,L,R=301]