2014-02-11 32 views
0

我有以下重寫規則將任何conetnt從主機hostA.com重定向到新主機hostB.com的主頁。 我也想瀏覽器的網址更改爲www.HostB.com主機之間的URL重寫和重定向

<rewrite> 
     <rules> 
      <rule name="301 redirect entire site" stopProcessing="true"> 
       <match url="^hostA(.*)$" /> 
       <action type="Redirect" redirectType="Permanent" url="http://www.hostB.com" appendQueryString="true" /> 
      </rule> 
     </rules> 
    </rewrite> 

但是,這並不工作。我該如何解決這個問題。

+0

什麼的輸出中是什麼樣子的HTTP錯誤你得到,或者沒有應用重定向規則? –

+0

正在應用它,但瀏覽器網址並未更改。此外,我必須爲舊主機上的新主機添加綁定。我不知道在設置DNS之後這是否有必要。 – jpo

回答

1

可以DOIT這樣

<rule name="domain redirect" enabled="true" stopProcessing="true"> 
     <match url="^hostA(.*)$" /> 
     <action type="Redirect" url="http://hostb.example.com/{R:0}" appendQueryString="true" /> 
    </rule> 
+0

所以要重定向到只是主機的主頁,我需要將最後一行改爲。對? – jpo

+0

是的,這是正確的 –

+0

由於某種原因,瀏覽器URL不會改變,但重定向發生。 – jpo