2017-09-10 27 views
0

我在IIS中设置了一个网站,并且该网站有两个应用程序(如下面的快照所示)。IIS自动将http重定向到https以在网站中选择应用程序

enter image description here

我必须启用对应用程序的HTTPS。我已安装SSL证书并设置应用程序以使用https而不是http。现在我想实现从http到https的autoredirect,仅用于测试应用程序(PersonalCornerTest)。 我使用UrlRewrite使用下面的链接作为参考,

https://www.sslshopper.com/iis7-redirect-http-to-https.html(方法1) 和 https://blogs.msdn.microsoft.com/kaushal/2013/05/22/http-to-https-redirects-on-iis-7-x-and-higher/(方法1)

我用于测试应用的配置文件中的下面设置,

<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}" /> 

然而,问题是,将下面的代码,当用户试图访问使用http在测试现场后,网址,它会自动重定向到https,但是会转到非测试网站(即PersonalCorner)而不是测试应用程序,这是令人困惑的。

任何人都可以让我知道我在上述设置中做了什么错误吗?我只想为测试应用程序实现autoredirect。

+0

什么是网址格式?你的测试和非测试网站? –

+0

您是否在您的测试应用程序的web.config中添加了此规则? –

+0

网址格式为http://example.com/PersonalCorner/(用于非测试)和http://example.com/PersonalCornerTest(用于测试网站)。所以当我输入http://example.com/PersonalCornerTest时,它会自动重定向到https://example.com/PersonalCorner(这是非测试) –

回答

1

自己回答我的问题!

的下方配置固定的问题,

<rewrite> 
      <rules> 
       <rule name="Redirect to https" 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="false" /> 
       </rule> 
      </rules> 
     </rewrite> 

参考:How to force HTTPS using a web.config file

相关问题