需求:在IIS 7、7.5、8.0、8.5和ASP.NET中刪除HTTP響應(yīng)標(biāo)頭,修改或隱藏IIS 7、7.5、8.0、8.5的Server頭信息。
解決方案:使用url-rewrite規(guī)則
1、先安裝 http://www.iis.net/downloads/microsoft/url-rewrite
腳本之家下載 https://www.jb51.net/softs/614384.html
2、把下面復(fù)制到web.config
<rewrite>
<outboundRules rewriteBeforeCache="true">
<rule name="Remove Server header">
<match serverVariable="RESPONSE_Server" pattern=".+" />
<action type="Rewrite" value="Apache" />
</rule>
</outboundRules>
</rewrite>
注意 ,這為返回的Server協(xié)議頭,value按需求修改。

3、重啟IIS
如果上面的操作不行可以參考下面的文章
刪除X-Powered-By HTTP頭
IIS7中移除X-Powered-By HTTP頭的方法是:
1 啟動(dòng)IIS Manager
2 點(diǎn)擊計(jì)算機(jī)名
3 選擇你需要修改的站點(diǎn)并 雙擊 HTTP響應(yīng)頭部分
4 所有的自定義HTTP頭全在這里了,刪除相應(yīng)的頭僅需要點(diǎn)擊右邊的 Remove 按鈕
刪除X-AspNet-Version HTTP頭
修改web.config配置文件 在 <system.web> 塊內(nèi)添加下面這行
<httpRuntime enableVersionHeader="false" />
刪除X-AspNetMvc-Version HTTP頭
在Global.asax的Application_Start事件中將MvcHandler類的DisableMvcResponseHeader屬性設(shè)置為True
MvcHandler.DisableMvcResponseHeader = True
刪除Server HTTP頭
下載UrlScan
Download the setup MSI file for UrlScan 3.1 from one of the following URLs to your computer:
x86: http://www.microsoft.com/downloads/details.aspx?FamilyID=ee41818f-3363-4e24-9940-321603531989
x64: http://www.microsoft.com/downloads/details.aspx?FamilyID=361e5598-c1bd-46b8-b3e7-3980e8bdf0de
安裝UrlScan(需要安裝IIS-Metabase,即IIS 6 元數(shù)據(jù)庫兼容性組件)后,
修改 C:\Windows\System32\inetsrv\urlscan\UrlScan.ini 文件,設(shè)置 RemoveServerHeader=1
然后重啟IIS
好了這篇文章就介紹到這了,希望大家以后多多支持腳本之家。