在IIS到HTTPS URL重写从http不工作, [英] URL Rewrite on IIS from http to https is not working,

查看:416
本文介绍了在IIS到HTTPS URL重写从http不工作,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。在 IIS 我有一个网站有两个端口 80 443(HTTPS)。我想重定向从用户到 HTTPS 所有的 HTTP 请求。我还添加了重写规则到https ,但是当我在浏览器中输入的http://本地主机/网站它给了我相同的页面。我需要用户重定向到 HTTPS://本地主机/网站

I have a problem. On IIS I got a web-site with two ports 80 and 443(https). I want to redirect all the http requests from user to https. I also added Rewrite rule to https, but when I enter in browser http://localhost/site it gives me the same page. I need to redirect user to httpS://localhost/site.

也许这是因为我的本地配置的?

Maybe this is because of my local configurations?

和我停用需要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>

感谢您。

推荐答案

下面是我们用在生产的确切规则IIS 7的网站重定向从HTTP到HTTPS

Below is the exact rule we use on a production IIS 7 site to redirect all request from HTTP to 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>

有与我们使用您发布什么,什么一些细微的差别。此外,由于你是本地主机上运行,​​则不会使用与Visual Studio内置的Web服务器,你会?我不认为这会处理IIS重写规则。

There are some minor differences between what you have posted and what we use. Also, since you are running on local host, you wouldn't be using the built-in web server with visual studio would you? I don't think it will process IIS rewrite rules.

这篇关于在IIS到HTTPS URL重写从http不工作,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆