2017-06-30 271 views

回答

0

试试这个它可以帮助你:

<system.webServer> 
    <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="Permanent" 
      url="https://{HTTP_HOST}/{R:1}" /> 
</rule> 
    </rules> 
</rewrite> 
</system.webServer> 
+0

感谢Praveen,但这不关心www我猜 – geekonweb

0

您可将您的流量使用Global.asax以及使用https。

方法名称:Application_BeginRequest

您的代码重新定向将是这个样子

strProtocol = "https"; 

if (HttpContext.Current.Request.Url.ToString().ToLower().StartsWith("http:") == true) 
{ 
    Response.Redirect(strProtocol + "://" + strYourHostName + strYourRemainingURL, false); 
} 

你可以保持在web.config中的协议和主机名,并从那里挑选。

相关问题