2011-09-21 65 views
0

我有一些網站上http://mydomain.com/mysite,很少有動態子網站http://mydomain.com/mysite/category1http://mydomain.com/mysite/othercategory2網址rewritting多個域和子文件夾asp.mvc

我想訪問的mysite/{動態類別名稱}從其他地址http://otherdomain.com。它應與mysite的和mysite的/組別工作...

http://otherdomain.com should show http://mydomain.com/mysite 
http://otherdomain.com/category1 should show http://mydomain.com/mysite/category1 

但不與重定向客戶

+0

這可以只使用IIS重定向設置完成。 – bzlm

+0

但是網站託管在一個複製池和網站(多個主機名:mydomain.com和otherdomain.com) – marcinn

回答

0

這可以通過URL重寫來完成。你基本上需要用hostname otherdomain.com將所有請求重寫爲/ mysite/*。這可以通過以下重寫規則來實現:

<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <rule name="Rewrite all request for otherdomain.com to /mysite"> 
        <match url="(.*)" /> 
        <conditions> 
         <add input="{HTTP_HOST}" pattern="^otherdomain\.com$" /> 
        </conditions> 
        <action type="Rewrite" url="/mysite/{R:0}" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 

另一種方案是在IIS中設置一個二級站點,與主機otherdomain.com在同一個IP,但讓該網站點的路徑物理路徑/ mysite文件夾。但是,如果你需要otherdomain.com上的mydomain.com的ASP.NET MVC應用程序,那當然也不會起作用。但是,如果otherdomain.com是例如,它可以是一個解決方案僅用於提供靜態內容(圖像,CSS,腳本)。