IIS 8.5 URL重写强制重定向http - > https for non www

时间:2015-01-15 10:10:07

标签: redirect iis https url-rewriting rewrite

我开始使用重写模块有一个"简单" IIS 8.5 URL重写重定向http - > https为非www站点。

问题:如果域名与action url参数匹配,我总是得到" http://"而不是" https://"。

这是我的规则:

<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="Permanent" />
    </rule>
  </rules>
</rewrite>

我无法发布多个链接,因此&#34;域名&#34; = crm.test.com。具有重写规则的站点绑定到端口2080上的&#34;域&#34; = crm.test.com。

我想重定向&#34; http://&#34;到&#34; http s ://&#34;,但我总是得到&#34; http://&#34;作为回应的位置:

   HTTP/1.1·302·Redirect
   Connection:·close
   Content-Length:·176
   Date:·Thu,·15·Jan·2015·08:21:21·GMT
   Location:·http://domain/                      <--
   Content-Type:·text/html;·charset=UTF-8
   Server:·Microsoft-IIS/8.5
   X-Powered-By:·ASP.NET

我尝试了以下操作url参数:

不工作:

"https://{HTTP_HOST}/{R:1}" -> http://domain/
"https://domain/{R:1}" -> http://domain/
"https://{HTTP_HOST}:443/{R:1}" -> http://domain/
"https://{HTTP_HOST}/1" -> http://domain/1/

工作:

"https1://{HTTP_HOST}/{R:1}" -> https1://domain/
"https://{HTTP_HOST}:444/{R:1}" -> https://domain:444/
"https://test.domain.com/{R:1}" -> https://test.domain.com/
"https://www.google.com/{R:1}" -> https://www.google.com/

我找到了&#34; URL Rewrite on IIS from http to https is not working,&#34;,但这并没有解决我的问题。

我错过了什么吗?

3 个答案:

答案 0 :(得分:2)

以下为我们工作:

            <rule name="HTTP Redirect to HTTPS" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTPS}" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
            </rule>

答案 1 :(得分:2)

0。 k。,我找到了解决方案 - 链接翻译是由iis前面的tmg 2010引起的。 tmg有一个错误,在301的情况下,链接转换将https链接重置为http。问题解决方案如下所述:

http://blog.sanibellogic.com/2008/09/default

http://support.microsoft.com/kb/924373

谢谢大家。

答案 2 :(得分:0)

您还可以使用URL重写来配置带或不带www的重定向域。 SSL证书仅包括:www FQDN。

web.config示例(域示例为:sysadmit.com):

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#1D1D1D"        android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar">
    </android.support.v7.widget.Toolbar>

摘自:http://www.sysadmit.com/2017/05/windows-iis-redirigir-http-https.html

相关问题