假设我的服务器ip地址是:http://192.168.1.100 (非SSL)
我的域名是:https://helloserver.com (SSL)
如果有人通过域helloserver.com访问我的网站,服务器应该自动地将其重定向到HTTPS。我通过应用下面的规则成功地做到了这一点
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent"
url="https://{HTTP_HOST}/{R:1}" />
</rule> 但是,如果有人从IP地址本身访问网站,就会产生证书错误,因为ip地址没有证书。
我如何修改以下规则:当IP地址用于访问网站时,它将使用HTTP而不是重定向的HTTPS规则
我猜这与<match url="" />条件有关。
有什么想法吗?
发布于 2018-09-02 14:16:55
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="^helloserver.com$" />
</conditions>
<action type="Redirect" redirectType="Permanent"
url="https://{HTTP_HOST}/{R:1}" />
</rule> https://stackoverflow.com/questions/52136965
复制相似问题