Add custom header based on file type

前端 未结 1 831
有刺的猬
有刺的猬 2020-11-30 08:57

We are trying to add a custom header (X-Robots-Tag) for sitemap files in IIS 7.5. However, it does not appear that IIS supports custom headers based on a file type or wildca

相关标签:
1条回答
  • 2020-11-30 09:23

    You can use the IIS UrlRewrite module and add a custom outbound rule to configure the custom header. Here is a sample rule you may want to use:

      <system.webServer>
        <rewrite>
          <outboundRules>
            <rule name="Set custom HTTP response header">
              <match serverVariable="RESPONSE_X_Robots_Tag" pattern=".*" />
              <conditions>
                <add input="{REQUEST_URI}" pattern="\.xml\.gz$" />
              </conditions>
              <action type="Rewrite" value="The value you need for this header"/>
            </rule>
          </outboundRules>
        </rewrite>
      </system.webServer>
    

    More info: UrlRewrite documentation

    0 讨论(0)
提交回复
热议问题