• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

google is showing wordpress sitemap in search results

Question

Hussam Al-tayeb    22

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*

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
Hussam Al-tayeb    22

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

Share this post


Link to post
Share on other sites
  • 0
Steven P.    13,838

If you can't disable it from the SEO plugin why not create the file yourself and chmod it so it can't be overwritten? Just a thought?

Share this post


Link to post
Share on other sites
  • 0
Hussam Al-tayeb    22

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.

Share this post


Link to post
Share on other sites
  • 0
Steven P.    13,838

Did it for you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.