2012-09-11 127 views
1

我們有一個主要地址example1.example.com,並且我們爲此地址頒發了一個Https證書。但是主代碼在example2.example.com上,我們用來將第一個重定向到這個。 現在我們想要使用https,我想知道我們是否可以這樣做。我們在第二臺服務器上沒有任何https證書。IIS 7.0將https重定向到http

+1

您是否將它們發送到example2上的頁面,以便它們離開example1?你使用ASP.NET還是其他框架? –

+0

是的,example1.example.com沒有代碼,因此它們可以在example2.example.com上的頁面上工作。 –

+0

我們正在使用ASP.NET –

回答

0

在Global.asax中我有這樣的塊:

 if (Request.ServerVariables["HTTPS"] != "on") 
     { 
      Response.Redirect(Request.Url.AbsoluteUri.Replace("http://", "https://"), true); 
      return; 
     } 

這將打開HTTP請求到HTTPS,你會想要做的例1,例2若指回例1。

對於你想做的事,這應該工作:

 if (Request.ServerVariables["HTTPS"] == "on") 
     { 
      Response.Redirect(Request.Url.AbsoluteUri.Replace("https://", "http://"), true); 
      return; 
     } 
1

對於我的IIS 7.x的做重定向的最好和最簡單的方法是用微軟的URL Rewite模塊:

  • 找到here
  • 和很多不同的配置實例,here