Created
October 27, 2015 06:58
-
-
Save rriifftt/083ecbd2f7c852b45d19 to your computer and use it in GitHub Desktop.
powershell で X-AspNet-Version ヘッダを削除する ref: http://qiita.com/satoshi_iwashita/items/6751e9b87eae0cf08bba
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
<httpRuntime enableVersionHeader="false" /> |
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