2013-04-16 84 views

回答

0

我認爲你使用的是II7或更高?

IIS有一個簡單的HTTP重定向功能,可在IIS中列出的每個站點都可用。

確保您處於功能視圖中。點擊你想要重定向的網站(在你的情況下它的http://two.example.com

你應該看到這個。雙擊HTTP重定向IIS View

你應該看到這個。在這裏輸入您的重定向URL(在你的情況下,其http://two.example.com/subfolder

HTTP Redirect View

+0

這會將所有流量重定向到目的地。我只想爲某個域重定向,並將其重定向到同一個域上的子文件夾。 – Tallday

0

This existing question應該解決您的問題

<system.webServer> 
<rewrite> 
    <rules> 
     <rule name="Root Hit Redirect" stopProcessing="true"> 
      <match url="^$" /> 
      <action type="Redirect" url="/menu_1/MainScreen.aspx" /> 
     </rule> 
    </rules> 
</rewrite> 
</system.webServer> 
+0

是的,謝謝我已經嘗試過,但這將爲兩個域。我只想重定向two.example.com – Tallday

3

您需要添加一個匹配條件的HTTP_HOST

<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="two.example.com Redirect" stopProcessing="false"> 
       <match url="^\/?$" /> 
       <conditions> 
        <add input="{HTTP_HOST}" pattern=".*two\.example\.com.*" /> 
       </conditions> 
       <action type="Redirect" redirectType="Found" url="http://two.example.com/subfolder/{R:0}" /> 
      </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 

這裏有一個體面的模塊總體參考: http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference

一個非常晚的答案,但希望它可以幫助某人。

+0

這對我造成了重定向循環。你知道爲什麼嗎? –

+0

@RobbieSmith你可以嘗試使匹配url =「^ \ /?$」?我覺得在寫這篇文章的時候我必須回到一個有效的例子,但現在看,我認爲你只應該在這種情況下匹配url的根目錄,以確保規則不會在重定向到子目錄。讓我知道,如果這是正確的,我會編輯答案。謝謝 – frax

+0

我最終做了一個愚蠢的人類把戲。在我的根目錄下,我創建了一個default.aspx文件,內容爲<%Response.Redirect(「http://.../subfolder」)%>' –

相關問題