Created
October 27, 2015 10:34
-
-
Save rriifftt/379f1e66a5518610a6bd to your computer and use it in GitHub Desktop.
powershell で X-AspNet-Version ヘッダを削除する ref: http://qiita.com/satoshi_iwashita/items/5d2a3bf91a79096955ed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.web> | |
<httpRuntime enableVersionHeader="false" /> | |
</system.web> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c:\windows\system32\inetsrv\appcmd.exe set config -section:system.web/httpRuntime -enableVersionHeader:false /commit:webroot /clr:4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.webServer> | |
<rewrite> | |
<allowedServerVariables> | |
<add name="RESPONSE_X-ASPNET-VERSION" /> | |
</allowedServerVariables> | |
<outboundRules> | |
<rule name="RESPONSE_X-ASPNET-VERSION"> | |
<match serverVariable="RESPONSE_X-ASPNET-VERSION" pattern=".+" /> | |
<action type="Rewrite" /> | |
</rule> | |
</outboundRules> | |
</rewrite> | |
</system.webServer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add allowedServerVariables | |
$asv = Get-WebConfigurationProperty ` | |
-filter "//rewrite/allowedServerVariables/add"` | |
-name name | |
if ($asv -eq $null) | |
{ | |
Add-WebConfigurationProperty ` | |
-Filter "//rewrite/allowedServerVariables" ` | |
-PSPath "IIS:\" ` | |
-Name "Collection" ` | |
-Value @{name="RESPONSE_X-ASPNET-VERSION"} | |
} | |
# add rule | |
$rule = Get-WebConfigurationProperty ` | |
-filter "//rewrite/outboundRules/rule[@name='REMOVE_X-ASPNET-VERSION']/match"` | |
-name serverVariable | |
if ($rule -eq $null) | |
{ | |
Add-WebConfigurationProperty ` | |
-Filter "//rewrite/outboundRules" ` | |
-PSPath "IIS:\" ` | |
-Name "Collection" ` | |
-Value @{name="REMOVE_X-ASPNET-VERSION"} | |
Set-WebConfiguration ` | |
-Filter "//rewrite/outboundRules/rule[@name='REMOVE_X-ASPNET-VERSION']/match" ` | |
-PSPath "IIS:\" ` | |
-Value @{serverVariable="RESPONSE_X-ASPNET-VERSION";pattern=".+"} | |
Set-WebConfiguration ` | |
-Filter "//rewrite/outboundRules/rule[@name='REMOVE_X-ASPNET-VERSION']/action" ` | |
-PSPath "IIS:\" ` | |
-Value @{type="Rewrite"} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment