如何使用Web配置删除X-Powered-By标头

时间:2017-11-21 06:19:15

标签: html iis http-headers web-config

您好我试图通过使用我的web.config删除 X-Powered-By标题。 到目前为止,这是我的web.config文件,

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rule" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                            <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
<httpProtocol>
   <customHeaders>
    <clear />
       <remove name="X-Powered-By" />
   </customHeaders>
</httpProtocol>
    </system.webServer>
</configuration>

但是一旦我检查,它仍然显示x-powered-by ....

2 个答案:

答案 0 :(得分:0)

<httpProtocol> 
 <customHeaders> 
  <remove name="X-Powered-By"/>
 </customHeaders> 
</httpProtocol>

请参见此处以了解其他选项:https://blog.insiderattack.net/configuring-secure-iis-response-headers-in-asp-net-mvc-b38369030728

答案 1 :(得分:-1)

尝试将其放在index.php文件的顶部:

header_remove("X-Powered-By");

http://php.net/manual/en/function.header-remove.php