Bar*_*cer 2 iis web-config url-rewriting
所以我一直在尝试使用以下内容重写:
<rules>
<rule name="HttpToHttps" stopProcessing="true"/>
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{URL}"/>
</rule>
<rules>
Run Code Online (Sandbox Code Playgroud)
在两个环境中,这会重定向.在第三种环境中,它不起作用.它不起作用,看着一个小提琴日志,我看到完整网址的http调用.当它重定向到https时,它会删除HTTP_HOST之后的所有内容.
所以使用以下网址:
不安全://www.mysite.com/page.aspx VAR1 = 1&VAR2 = 2
在两个环境中,它变成了
安全://www.mysite.com/page.aspx VAR1 = 1&VAR2 = 2
在第三个它成为:
安全://www.mysite.com
我尝试将其重写为https:// {HTTP_HOST} {HTTP_URL},并在前两个环境中将{URL}加倍:
安全://www.mysite.com/page.aspx VAR1 = 1&VAR2 = 2&VAR1 = 1&VAR2 = 2
我对web.configs不是很有经验,有点学习,所以如果有人对这里发生的事情有任何意见,我将不胜感激.如果它与任何东西有任何关系,则第三个环境位于两个负载均衡的服务器上.
小智 5
Ruslany在他的博客上有几个IIS URL Rewrite示例,HTTP到HTTPS就是其中之一:
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参见http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/.
| 归档时间: |
|
| 查看次数: |
6908 次 |
| 最近记录: |