您可以在IIS8 url重写映射中使用请求或响应标头吗?
问题描述:
我设置了一些规则来重写某些URL以使事情变得更加整洁,但由于我们的服务器只能通过使用HTTP的负载均衡器访问,因此存在HTTPS问题。负载平衡器添加了我希望用来代替IIS服务器变量{HTTPS}的请求标头Front-End-Https。这可能吗?您可以在IIS8 url重写映射中使用请求或响应标头吗?
喜欢的东西:
<rule name="RemoveAspxExtension" enabled="true" stopProcessing="true">
<match url="(.*).aspx$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{URL}" pattern="\.axd$" negate="true" />
<add input="{URL}" pattern="\.aspx/" negate="true" />
<add input="{URL}" pattern="\.asmx" negate="true" />
<add input="{URL}" pattern="\.ashx" negate="true" />
<add input="{URL}" pattern="\.css$" negate="true" />
<add input="{URL}" pattern="\.js$" negate="true" />
<add input="{URL}" pattern="\.png$" negate="true" />
<add input="{URL}" pattern="\.jpg$" negate="true" />
<add input="{URL}" pattern="\.gif$" negate="true" />
<add input="{URL}" pattern="\.xml$" negate="true" />
<add input="{URL}" pattern="\.txt$" negate="true" />
<add input="{URL}" pattern="\.html$" negate="true" />
<add input="{URL}" pattern="/scripts/" negate="true" />
<add input="{URL}" pattern="/styles/" negate="true" />
<add input="{URL}" pattern="/secured/" negate="true" />
</conditions>
<action type="Redirect" url="{MapProtocol:{ToLower:{Front-End-Https}}}://{HTTP_HOST}/{R:1}" appendQueryString="true" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="MapProtocol" defaultValue="http">
<add key="on" value="https" />
<add key="off" value="http" />
</rewriteMap>
</rewriteMaps>
答
是的,你可以通过在前面添加{HTTP_使用任何HTTP标头,SOM您可以使用{HTTP_Front中档-HTTPS},它应该工作。
干杯。我确信这很简单,但我能找到的所有东西都是关于设定值而不是使用它们。这工作完美。 –