重定向的https:// WWW到https://通过web.config中

问题描述:

我想任何重定向到https://domain.com
我发现这个代码:重定向的https:// WWW到https://通过web.config中

<rewrite> 
    <rules> 
     <rule name="SecureRedirect" stopProcessing="true"> 
     <match url="^(.*)$" /> 
     <conditions> 
      <add input="{HTTPS}" pattern="off" /> 
      <add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" /> 
     </conditions> 
     <action type="Redirect" url="https://{C:2}" redirectType="Permanent" /> 
     </rule> 
    </rules> 
    </rewrite> 

及其工作除了在https://www.domain.com
我的虚拟服务器是Windows Server 2012与IIS 8,并且域是https://kajsystem.com

我会建议使用IIS 8配置,包括使用URL重写模块,它可以处理转发并保留整个请求的URL。在MSDN网站上有一篇相当全面的文章覆盖了这个:

MSDN redirect on IIS 7 and higher