• 0

google is showing wordpress sitemap in search results


Question

Google is showing the actual wordpress sitemap.xml in search results which I don't want.
The sitemap is generated by all in one seo plugin. it's a dynamically generated file.
there is no real sitemap.xml file on the server.
I want to noindex it.
I tried those rules in htaccess but they don't work. this is probably due to the fact that the file isn't real.

<FilesMatch "sitemap\.xml">
Header set X-Robots-Tag "noindex"
</FilesMatch>

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

<FilesMatch "\.xml$">
Header set X-Robots-Tag "noindex"
</FilesMatch>

Any other way to do it?

 

*Edited for better wording*

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

I already tried that :) (notice the three rules in first post) but it won't work on  "virtual" files.

Any way for a rule to intercept a requested string?

 

Edit: I got it.

I added 

header("X-Robots-Tag: noindex", true);

to the script that generates the virtual sitemap.xml

 

so now it is:

echo '<?xml-stylesheet type="text/xsl" href="' . $plugin_path . 'sitemap.xsl"?>' . "\r\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\r\n";
header("X-Robots-Tag: noindex", true);

How do I mark a thread as solved?

Edited by Hussam Al-tayeb
Link to comment
Share on other sites

  • 0

Because I still want it to be auto-generated from posts.

I just want google to not place the actual sitemap.xml itself in google search results.

Link to comment
Share on other sites

This topic is now closed to further replies.