2015-04-12 61 views
1

例如,我有一個基於經典ASP.NET和IIS 7.5的Web應用程序www.mywebsite.com。現在我註冊了另一個域名www.mywebsite.cc。在我的Web應用程序中,我想創建子文件夾/cc,並以某種方式透明地將所有請求從www.mywebsite.cc/something重寫爲www.mywebsite.com/cc/something。爲什麼我需要這個?我希望這兩個網站都共享相同的靜態變量,緩存,數據庫連接等。請指出我必須挖掘哪些技術才能實現我所需要的。具有多個域名的單個Web應用程序

回答

0

有幾種方法可以做到這一點,你可以嘗試URL重寫。您的代碼可能看起來像這樣,但您需要調整字符串後面的行:「^ something /?$ |^something /(.*)$」以包含正確的匹配代碼。這應該讓你開始,希望別人能夠評論正確的比賽代碼。

<rewrite> 
    <rules> 
    <remove name="RedirectToUtility"/> 
    <rule name="RedirectToUtility" stopProcessing="true"> 
     <match url="^something/?$|^something/(.*)$"/> 
     <conditions/> 
     <serverVariables/> 
     <action type="Redirect" url="http://www.mywebsite.com/cc/something/{R:1}"/> 
    </rule> 
    </rules> 
</rewrite> 

http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module

相關問題