Adding X-Robot-Tag to response header in Sitecore 8

Arun Kumar

I have got a website setup in Sitecore. My sitemap is an item in sitecore which is under the homepage.

I am able to access my sitemap by typing following URL: http://example.com/xmlsitemap Whereas xmlsitemap is the name of the item in Sitecore. Which has the rendering to get the XML sitemap given below:

XmlDocument SiteMap = new XmlDocument();
SiteMap.Load(System.Web.HttpContext.Current.Server.MapPath("~/") + "//SiteMap//Sitemap-" + Sitecore.Context.Site.SiteInfo.Name + ".xml");
return this.Content(SiteMap.InnerXml, "text/xml");

I have got multiple site setup in sitecore. That's why I created sitemap as an Item in sitecore. So that it gets the right sitemap for each website.

The issue is when I submit this sitemap to google using the URL. It is indexing the sitemap URL as well and it is appearing in the actual results.

I know I can stop google from indexing my sitemap by adding X-Robot-Tag: noindex. But I can't do it IIS because it is not an item inside the website directory.

Any ideas on how that can be achieved?

jammykam

You can specify the header in your web.config by specifying it within a location node.

<configuration>
...
    <location path="xmlsitemap">
        <system.webServer>
            <httpProtocol>
                <customHeaders>
                    <add name="X-Robots-Tag" value="noindex" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </location>
</configuration>

You can add this manually, the file does not need to be physically present in IIS.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Adding X-Robot-Tag to response header in Sitecore 8

From Dev

get response header robot framework

From Dev

Adding response header in Servant

From Dev

Adding header in response in filter?

From Dev

adding http response header

From Dev

Adding header to response for specific URLs with HAproxy

From Dev

Sitecore 8 - Adding images, callouts and videos in RTF field

From Dev

Adding "Internal keywords" in Experiance Profile of Sitecore 8 Analytics

From Dev

Sitecore 8: Adding a color widget to the Rich Text Editor

From Dev

IE 8 Automatically Closing <header> tag

From Dev

x-power-by display in response header

From Dev

Precedence of X-Robots-Tag header vs robots meta tag

From Dev

ASP.NET 5 Middleware "no response received" after adding header

From Dev

WCF adding additional HTTP header to HTTP response for transporting SOAP message

From Dev

Angularjs: Why does adding an authorization header cause a -1 status response?

From Dev

not getting success response when adding custom headers with Authorization header in get header() volley

From Dev

not getting success response when adding custom headers with Authorization header in get header() volley

From Dev

How to use the HTML5 header tag into Internet Explorer 8?

From Dev

What is adding "X-PHP-Originating-Id" to my email header?

From Dev

Adding X-CSRF-Token header globally to all instances of XMLHttpRequest();

From Dev

R: read.csv adding sub-script "X" in header

From Dev

Varnish automagically adding load balancer IP to X-Forwarded-For header

From Dev

What is globally adding an "x-frame-options: deny" header?

From Dev

R: read.csv adding sub-script "X" in header

From Dev

What is globally adding an "x-frame-options: deny" header?

From Java

How to disable 'X-Frame-Options' response header in Spring Security?

From Dev

Retrofit 2.x : Log Header for request and response

From Dev

Playframework 1.x Unauthorized response with Negotiate header

From Dev

Understanding the x-ms-resource-usage in DocumentDB response header

Related Related

  1. 1

    Adding X-Robot-Tag to response header in Sitecore 8

  2. 2

    get response header robot framework

  3. 3

    Adding response header in Servant

  4. 4

    Adding header in response in filter?

  5. 5

    adding http response header

  6. 6

    Adding header to response for specific URLs with HAproxy

  7. 7

    Sitecore 8 - Adding images, callouts and videos in RTF field

  8. 8

    Adding "Internal keywords" in Experiance Profile of Sitecore 8 Analytics

  9. 9

    Sitecore 8: Adding a color widget to the Rich Text Editor

  10. 10

    IE 8 Automatically Closing <header> tag

  11. 11

    x-power-by display in response header

  12. 12

    Precedence of X-Robots-Tag header vs robots meta tag

  13. 13

    ASP.NET 5 Middleware "no response received" after adding header

  14. 14

    WCF adding additional HTTP header to HTTP response for transporting SOAP message

  15. 15

    Angularjs: Why does adding an authorization header cause a -1 status response?

  16. 16

    not getting success response when adding custom headers with Authorization header in get header() volley

  17. 17

    not getting success response when adding custom headers with Authorization header in get header() volley

  18. 18

    How to use the HTML5 header tag into Internet Explorer 8?

  19. 19

    What is adding "X-PHP-Originating-Id" to my email header?

  20. 20

    Adding X-CSRF-Token header globally to all instances of XMLHttpRequest();

  21. 21

    R: read.csv adding sub-script "X" in header

  22. 22

    Varnish automagically adding load balancer IP to X-Forwarded-For header

  23. 23

    What is globally adding an "x-frame-options: deny" header?

  24. 24

    R: read.csv adding sub-script "X" in header

  25. 25

    What is globally adding an "x-frame-options: deny" header?

  26. 26

    How to disable 'X-Frame-Options' response header in Spring Security?

  27. 27

    Retrofit 2.x : Log Header for request and response

  28. 28

    Playframework 1.x Unauthorized response with Negotiate header

  29. 29

    Understanding the x-ms-resource-usage in DocumentDB response header

HotTag

Archive