2014-02-19 44 views
2

我有以下網址與HTTPS URL rewritting

http://www.mywebsite.com/home

https://www.mywebsite.com/secure/reports/

當用戶進入上述網址我們加載

http://www.mywebsite.com/home.aspx

https://www.mywebsite.com/secure/reports.aspx

問題是,如果用戶輸入如https://www.mywebsite.com/home,則需要重定向到http://www.mywebsite.com/home。只是刪除變化HTTPS對HTTP,因爲它沒有固定

同樣,如果用戶輸入http://www.mywebsite.com/secure/reports,我們需要redurect確保https://www.mywebsite.com/secure/reports

回答

1

看到this

protected void Application_BeginRequest(Object sender, EventArgs e) 
{ 
    if (HttpContext.Current.Request.IsSecureConnection.Equals(false) && HttpContext.Current.Request.IsLocal.Equals(false)) 
    { 
    Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"] 
+ HttpContext.Current.Request.RawUrl); 
    } 
} 
+0

用戶故意將'https'改爲'http',反之亦然。我想阻止這一點。你的代碼是否適用於這兩種情況? – Billa