首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >您能在IIS8 url重写映射中使用请求或响应头吗?

您能在IIS8 url重写映射中使用请求或响应头吗?
EN

Stack Overflow用户
提问于 2016-01-13 10:19:31
回答 1查看 493关注 0票数 0

我设置了一些规则来重写某些urls以使事情更加整洁,但是HTTPS有问题,因为我们的服务器只能通过使用HTTP的负载均衡器访问。负载均衡器添加请求头前端-HTTPS,我想使用它来代替IIS服务器变量{HTTPS}。这个是可能的吗?

类似于:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-13 18:26:45

是的,通过在前面添加一个{HTTP_,您可以使用任何Header,您可以使用{HTTP-前端-Https},而且它应该可以工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34764019

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档