![](/img/trans.png)
[英]IIS Rewrite Rule in web.config to redirect HTTPS requests to HTTP
[英]IIS HTTP to HTTPS web.config rewrite doesn't return entire URL
所以我一直在尝试使用以下内容重写:
<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>
在两个环境中,此重定向应按其应有的方式进行。 在第三个环境中,它不起作用。 从一个提琴手的日志来看,我看到带有完整URL的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并没有很丰富的经验,虽然我一直在学习,所以如果有人对这里发生的事情有任何意见,将不胜感激。 如果它对任何事物都有影响,则第三个环境位于负载平衡的两个服务器上。
Ruslany在他的博客上有几个IIS URL Rewrite示例,HTTP to 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>
有关更多信息,请参见http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/ 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.