Nic*_*gas 6 asp.net-mvc https iis-7 http url-rewriting
我有个问题.在IIS我有一个网站有两个端口80和443(https).我想将http用户的所有请求重定向到https.我还补充说Rewrite rule to https,但是当我进入浏览器时,http://localhost/site它给了我相同的页面.我需要将用户重定向到httpS://localhost/site.
也许这是因为我的本地配置?
我禁用Require SSL了IIS.
The rule is:
<rewrite>
<rules>
<rule name="HTTPS Redirect">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="false" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
</rules>
</rewrite>
Run Code Online (Sandbox Code Playgroud)
谢谢.
Tom*_*mmy 15
以下是我们在生产IIS 7站点上使用的确切规则,以将所有请求从HTTP重定向到HTTPS
<configuration>
<system.webServer>
<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="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
您发布的内容与我们使用的内容之间存在一些细微差别.此外,由于您在本地主机上运行,您将不会使用带有visual studio的内置Web服务器吗?我认为它不会处理IIS重写规则.
我意识到这可能不是你的问题,但是我有一个类似的崩溃,这是由一个不同的问题引起的.
我启用了需要SSL,这导致网站不断返回403.因此,要使用此方法,您必须禁用SSL设置 - >需要SSL.
希望这有助于某人.
| 归档时间: |
|
| 查看次数: |
13218 次 |
| 最近记录: |