[英]IIS auto redirect http to https for select applications in a website
我在IIS中设置了一个网站,这个网站有两个应用程序(如下面的快照所示)。
我必须在应用程序上启用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}" />
但是,问题是,在添加以下代码后,当用户尝试使用URL中的http访问测试站点时,它会自动重定向到https,但是会重定向到非测试站点(即PersonalCorner)而不是测试应用程序,这是混乱。
谁能让我知道我在上面的设置中做了什么错误? 我想仅为测试应用程序实现autoredirect。
自己回答我的询问!
以下配置解决了这个问题,
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.