You are here:  » Probable solution: Stop indexing XML Sitemaps

Support Forum



Probable solution: Stop indexing XML Sitemaps

Submitted by IG on Thu, 2021-02-04 07:46 in

Hi David,

This is further to my previous topic. I think I found the solution and I don't want you to waste time on this.

It seems to me that the following code in .htaccess stops ALL XML feed sitemaps from being indexed:

{code saved}

Does this make sense to you?

Kind regards,
IG

Submitted by support on Thu, 2021-02-04 09:34

Hi,

That's strange for sitemap XML content to appear indexed - you certainly wouldn't want to exclude it via robots.txt as the file is _intended_ for robots...!

I would be careful adding an X-Robots-Tag header via .htaccess as it looks like that would be applied to _all_ scripts and could potentially de-index your site but it would be no problem to ouput it using header() within sitemap.php. To do this, look for the following code at line 4:

  header("Content-Type: text/xml");

...and REPLACE with:

  header("Content-Type: text/xml");
  header("X-Robots-Tag: noindex");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Thu, 2021-02-04 11:02

Hi David,

Somehow the code I wanted to put in .htacess was not complete. Here is the complete code, which should avoid the potential de-index problem:

 <IfModule mod_rewrite.c>
  <Files sitemap.xml>
   Header set X-Robots-Tag "noindex"
  </Files>
 </IfModule>

Having said that, your solution to make the change in sitemap.php is much better.

Thank you for your kind support,
IG

Submitted by support on Thu, 2021-02-04 12:17

Ah sorry, the forum wasn't displaying the markup without code tags; added above.

Whilst that would work for an actual filename sitemap.xml I think that would need to be sitemap.php in this case as that is the actual file requested; but as .htaccess has to be processed for every file request it would be more efficient just to use the header() call in sitemap.php if you're happy with that solution...

Cheers,
David.
--
PriceTapestry.com