2014-09-11 105 views
0

我想將我的網站上的特定URL轉發到另一個網站,我無法弄清楚如何在web.config文件中設置適當的值我的IIS服務器。在Windows Server 2012的IIS配置文件中的URL轉發IIS 8.5

比如我想轉發 www.example.com/ballot 到 ballot.example.com

到目前爲止,我已經試過以下,但它沒有任何影響到url

<rewrite> 
    <rules> 
    <rule name="Imported Rule 1" stopProcessing="true"> 
     <match url="^/ballot$" ignoreCase="false" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^example\.com$" /> 
     </conditions> 
     <action type="Redirect" redirectType="Permanent" url="http://ballot.example.com/" /> 
    </rule> 
    </rules> 
</rewrite> 

我在Rackspace Cloud站點上託管網站。

+0

有人嗎?我真的可以在這個上使用一些幫助。我正在尋找解決方案,但我沒有嘗試。我認爲這將與在apache服務器上使用.htaccess文件設置重定向一樣簡單。 – ReBoot 2014-09-12 18:34:52

回答

0

好的,我想出了這一個,我在這裏發佈解決方案給其他任何可能遇到類似情況的人。

如果你想一定網址像http://www.example.com/ballot重定向到http://ballot.example.com/

然後按照以下步驟

1)。如果尚不存在,請在www.example.com的Web根目錄下直接創建一個名爲ballot的目錄。 2)。創建一個Web.config文件,並將其放置在帶有以下內容的ballot目錄中。

<?xml version="1.0"?> 
<configuration> 
    <system.webServer> 
     <httpRedirect enabled="true" destination="http://ballot.example.com" httpResponseStatus="Permanent" /> 
    </system.webServer> 
</configuration> 

3)。確保您將目的地更改爲您的實際目的地。 4)。如果您在Rackspace的cloudsite上託管,則必須重新構建應用程序(不確定其他主機)。您可以通過刪除Web.Config文件(如果存在)並上傳新文件或單擊要嘗試重定向的網站的「常規設置」選項卡中的重建應用程序鏈接來重建應用程序。有關在Rackspace中重建應用程序的更多信息,請訪問:http://www.rackspace.com/knowledge_center/article/how-to-rebuild-an-aspnet-application-in-cloud-sites

另外這裏的網頁,我最終找到了解決什麼,我試圖完成一個鏈接:https://www.stokia.com/support/misc/web-config-response-redirect.aspx

我希望這可以幫助任何人可能會發現自己處於類似的情況。

相關問題