I have two domains pointing to the same hosting account. My code in the index.php page recognizes which domain and shows different content for each domain. However, both domains have the same sitemap.xml because there is only one sitemap in the public_html directory.

Is it possible to have two distinct sitemaps for the two domains?

  • Short answer: No. However, you can have two sitemaps with different file names...
    – closetnoc
    Oct 19, 2015 at 2:40
  • @closetnoc, Thats ok, but how would google find it because I thought google only finds the sitemap.xml file
    – MrDi
    Oct 19, 2015 at 2:41
  • You can submit each sitemap using Google Search Console by creating both domains then submitting the sitemaps that way.
    – closetnoc
    Oct 19, 2015 at 2:43
  • 1
    Nope. Should not. Google does not care about that kinda stuff. They just want decent sites that people enjoy.
    – closetnoc
    Oct 19, 2015 at 3:14
  • 1
    Anytime! We are here for you. There are some real exerts here so it is a good place to ask questions.
    – closetnoc
    Oct 19, 2015 at 3:17

3 Answers 3


This way comes straight out of our .htaccess and works like a charm:

RewriteCond %{HTTP_HOST} ^.*myhost\.com$
RewriteRule ^sitemap.xml$ sitemap-com.xml [NC]

RewriteCond %{HTTP_HOST} ^.*myhost\.ca$
RewriteRule ^sitemap.xml$ sitemap-ca.xml [NC]
  • I like your answer, however, I think the OP is using a single directory with PHP doing the work. If this is the case, your code example needs to change slightly to work properly. You are on the right track though!!
    – closetnoc
    Oct 19, 2015 at 16:28
  • No, our setup is pretty much the same. The .htaccess is parsed for all requests, and if there's a request to either domain with /sitemap.xml as the requested file, the .htaccess code supplies one of the two sitemaps created in the sitemaps directory. He just has to replicate the directory structure - or use no directory and rewrite the redirect code.
    – 0xCAFEBABE
    Oct 20, 2015 at 8:56
  • I've updated to fit the original question, based on comments. Jan 17, 2016 at 17:52

You can use 2 different sitemap files and add these seperate files to Google Webmaster Tools:

  • /sitemap1.xml
  • /sitemap2.xml

Another option is to use a rewriting mechanism to rewrite calls to the corresponding sitemap file. Using .htaccess or IIS-rewrite.

  • domain1.com/sitemap.xml rewrites to /sitemap1.xml
  • domain2.com/sitemap.xml rewrites to /sitemap2.xml

So to be clear I will start from the WMT and work back to your server. Tl;DR Yes you can.

Each domain needs to have a separate WMT account for both it and for its www. version. Specify the preferred domain.

Put each domains sitemap in a separate, DIFFERENT NAMED, folder. Ensure you can publicly resolve that sitemap. Test the sitemap with WMT.

Browse to that folder and submit the sitemap.xml for each domain.

Verify in a day that it is crawling appropriately.

This does not depend on anything external to your current setup. You already have resolution sorted out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.