简体   繁体   English

IIS中的HTTP到https

[英]http to https in IIS

I realize this is a simple question, but I'm just not finding the answer. 我意识到这是一个简单的问题,但我没有找到答案。 I've applied the below rule... 我应用了以下规则...

<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="Found" url="https://{HTTP_HOST}/{R:1}" />
            </rule>
          </rules>
        </rewrite>

The url I'm interested in has the pattern 我感兴趣的网址具有模式

http://[domain]/[directory]/[aspx page]

So http://example.com/funstuff/thefair.aspx 所以http://example.com/funstuff/thefair.aspx

The result of the rewrite is http://[domain]/[an_aspx_page] 重写的结果是http:// [domain] / [an_aspx_page]

So the rewrite is removing the directory. 因此,重写操作是删除目录。

I assumed the {R:1} specifies a parameter that will be rewritten, and I tried https://{HTTP_HOST}/{R:1}/{R:2}, but this result in a 500 error. 我假设{R:1}指定了将被重写的参数,并且尝试使用https:// {HTTP_HOST} / {R:1} / {R:2},但是这会导致500错误。

I want to direct all traffic on this domain to https without changing the rest of the url entered by the user. 我想将此域上的所有流量定向到https,而不更改用户输入的其余网址。

Here's what we use on one of our sites to auto-redirect all traffic to the https version. 这是我们在一个站点上使用的将所有流量自动重定向到https版本的方法。 It also includes everything else in the url. 它还在网址中包含其他所有内容。

<rewrite>
      <rules>
          <clear />
          <rule name="Redirect to https" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                  <add input="{HTTPS}" pattern="off" ignoreCase="true" />
              </conditions>
              <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />
          </rule>
      </rules>
  </rewrite>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM