【发布时间】:2021-03-13 18:22:05
【问题描述】:
我有一个在 Windows Server 上托管的 React Web 应用程序。
在IIS 中,我创建了URL Rewrite 规则。当我从我们的网络中查看网站时,重写规则会起作用,它会从 HTTP 重定向到 HTTPS。
但是,由于端口 80 在公共端关闭,当我尝试在 HTTP 中查看网站时,它永远不会重定向并且只是超时。我假设这是因为自从端口关闭以来它从未真正点击过页面,因此重定向永远不会启动。
有没有办法让网站在该端口关闭的情况下仍重定向到 HTTPS?
这是我的web.config 文件的外观:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<httpRedirect enabled="false" destination="https://mywebsitehere.com" />
<rewrite>
<rules>
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://mywebsitehere.com/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
【问题讨论】:
-
不可能...只有通过防火墙配置才有可能。
标签: redirect iis https url-rewriting web-config