I have a asp.net website called Home running in IIS and I added a rewrite URL rule to change the server tag in the response header to Mine. It only works for some of the responses and not all of them.
For example: https://myDomain/Home/Default.aspx works. (Server: Mine) But https://myDomain/Home/ does not work (Server: Microsoft...)
The code of my rule that can be found in C:\\Windows\\System32\\inetsrv\\config\\applicationHost.config are the following:
<rewrite>
<allowedServerVariables>
<add name="RESPONSE_SERVER" />
</allowedServerVariables>
<globalRules>
<rule name="Remove Server">
<match url=".*" />
<serverVariables>
<set name="RESPONSE_SERVER" value="Mine" />
</serverVariables>
<action type="None" />
<conditions>
</conditions>
</rule>
</globalRules>
</rewrite>
I am removing the server version for security reasons, but if it does not work for all responses, it defines the point.
As far as I know, if you want to modify the reponse header's value. I suggest you could try to use url rewrite outbound rule instead of normal rule.
Please add below rule in the application.host file:
<rewrite>
<allowedServerVariables>
<add name="RESPONSE_SERVER" />
</allowedServerVariables>
<outboundRules>
<rule name="ModifyServer">
<match serverVariable="RESPONSE_SERVER" pattern=".*" />
<action type="Rewrite" value="Mine" />
</rule>
</outboundRules>
</rewrite>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.