2017-06-30 157 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中的協議和主機名,並從那裏挑選。

相關問題