我的web配置中有以下代码,可以将带有前缀" www“的URL和非SSL请求重定向到https:// mydomain.com,因为SSL证书是在没有www的域中注册的
<rewrite>
<rules>
<rule name="Remove WWW prefix and redirect to https" >
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" ignoreCase="true" />
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://mydomain.com/{R:1}" />
</rule>
</rules>
</rewrite>这就是结果:
1) http:// mydomain.com/something --> https:// mydomain.com/something (正确)
2) http:// www.mydomain.com/something --> https:// mydomain.com/something (正确)
3) https:// www.mydomain.com/ this ->显示证书错误(本网站安全证书有问题)
当您选择“继续此网站(不推荐)”时。在证书错误页面上,url被正确重写(https:// mydomain.com/ the )
如何确保不显示证书错误?
谢谢
发布于 2017-03-30 18:31:57
解决这个问题的一种方法是注册两个独立的规则:
发布于 2014-10-10 22:35:31
所以我们在我们的项目中使用它,这是有效的。
让我知道这对我有帮助:
<rewrite>
<rules>
<rule name="Redirect to https">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="Off"/>
<add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
<add input="{HTTP_HOST}" pattern="localhost" negate="true"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
</rule>
</rules>
</rewrite>当您访问本地计算机上的站点时,它也会忽略该请求。
发布于 2014-04-25 16:53:55
我不确定这一点,因为我在url重写方面没有太多经验,但尝试帮助也不会有什么坏处。
你可以试试这个
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://mydomain.com/{R:1}" redirectType="Permanent" />我在谷歌上搜索了很多,找到了这个,但它可能不会像你想的那样。
https://stackoverflow.com/questions/23287733
复制相似问题