【问题标题】:How to Remove X-Powered-By header using web config如何使用 Web 配置删除 X-Powered-By 标头
【发布时间】:2017-11-21 06:19:15
【问题描述】:

您好,我正在尝试使用我的 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....

【问题讨论】:

    标签: html iis http-headers web-config


    【解决方案1】:
    <httpProtocol> 
     <customHeaders> 
      <remove name="X-Powered-By"/>
     </customHeaders> 
    </httpProtocol>
    

    查看此处了解不同的选项:https://blog.insiderattack.net/configuring-secure-iis-response-headers-in-asp-net-mvc-b38369030728

    【讨论】:

      【解决方案2】:

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

      header_remove("X-Powered-By");
      

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-02-09
        • 2021-05-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-02-01
        • 2022-12-29
        • 2013-12-28
        相关资源
        最近更新 更多