[英]IIS 8.5 URL Rewrite force redirect http --> https for non www
我从重写模块开始,对于非www站点,“简单的” IIS 8.5 URL重写重定向http-> https有问题。
问题:如果域与操作url参数匹配,我总是得到“ http://”而不是“ https://”。
这是我的规则:
<rewrite>
<rules>
<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>
</rules>
</rewrite>
我无法发布几个链接,因此“ domain” = crm.test.com。 具有重写规则的站点在端口2080上绑定到“ domain” = crm.test.com。
我想将“ http://”重定向到“ http s ://”,但在响应中我总是以“ http://”作为位置:
HTTP/1.1·302·Redirect
Connection:·close
Content-Length:·176
Date:·Thu,·15·Jan·2015·08:21:21·GMT
Location:·http://domain/ <--
Content-Type:·text/html;·charset=UTF-8
Server:·Microsoft-IIS/8.5
X-Powered-By:·ASP.NET
我尝试了以下操作url参数:
无法运作:
"https://{HTTP_HOST}/{R:1}" -> http://domain/
"https://domain/{R:1}" -> http://domain/
"https://{HTTP_HOST}:443/{R:1}" -> http://domain/
"https://{HTTP_HOST}/1" -> http://domain/1/
工作:
"https1://{HTTP_HOST}/{R:1}" -> https1://domain/
"https://{HTTP_HOST}:444/{R:1}" -> https://domain:444/
"https://test.domain.com/{R:1}" -> https://test.domain.com/
"https://www.google.com/{R:1}" -> https://www.google.com/
我发现“ 从HTTP到https的IIS上的URL重写不起作用 ”,但这不能解决我的问题。
我错过了什么吗?
以下对我们有用:
<rule name="HTTP Redirect to HTTPS" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
好吧,我找到了解决方案-链接翻译是由iis前面的tmg 2010引起的。 tmg有一个错误,如果是301,则链接转换会将https链接重置为http。此处描述了一个解决方案的问题:
http://blog.sanibellogic.com/2008/09/default
http://support.microsoft.com/kb/924373
谢谢大家。
您也可以使用URL重写配置带或不带www的重定向域。 SSL证书仅包括:www FQDN。
web.config示例(域示例为:sysadmit.com):
<rewrite>
<rules>
<clear />
<rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^[^www]" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.sysadmit.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
摘自: http : //www.sysadmit.com/2017/05/windows-iis-redirigir-http-https.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.