我试图弄清楚为什么以下代码不起作用。这是我的 web.config 文件的副本:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="false" destination="https://" exactDestination="false" />
<rewrite>
<rules>
<rule name="server.child.domain.lcl redirect." patternSyntax="Wildcard" stopProcessing="true">
<match url="*server.child.domain.lcl/*" />
<action type="Redirect" url="https://server.child.org/application" />
</rule>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="StaticRedirects" />
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="false" destination="https://" exactDestination="false" />
<rewrite>
<rules>
<rule name="Domain redirect." patternSyntax="Wildcard" stopProcessing="true">
<match url="*Server.child.domain.lcl/*" />
<action type="Redirect" url="https://server.domain.org/application" />
</rule>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="StaticRedirects" />
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>
第一条规则是从本地域名重定向到公共域名。这与为公共域名安装证书的服务器位于同一台服务器上。
如果有人尝试在没有 SSL 的情况下访问网站,第二条规则应该从 HTTP 重定向到 HTTPS。
这两种方法似乎都不起作用。我尝试了几次,但似乎都没有用。有人能帮我吗?