2012-04-26 80 views
1

我試圖做301重定向,因爲我已經改變了域名。使用Windows Server和IM在web.config中添加以下規則。多個web.config重定向規則

<rule name="redirectDomain" stopProcessing="true"> 
        <match url="(.*)" /> 
        <action type="Redirect" url="http://replacement-cost.net/{R:1}" redirectType="Permanent" /> 
        <conditions logicalGrouping="MatchAny"> 
         <add input="{HTTP_HOST}" pattern="^(www.)?windshield-replacement-cost\.org$" /> 
        </conditions> 
       </rule> 

這是工作確定,所以只要所有頁面都在新網站上相同的名稱和文件結構的......除了那就是老域的根頁面。現在在http://replacement-cost.net/windshield-replacement-cost

是否有可能編寫另一個規則來重定向僅根?而有第二個規則重定向所有其他網頁?可能是某種執行順序?

東西acheive相同的結果,因爲這基本上是

如果ruleURLISROOT =真>轉到http://replacement-cost.net/windshield-replacement-cost

其他

與代碼重定向上述

任何幫助,將不勝感激。它花了我很長時間纔得到這個!由於

回答

4

這是應該的現有規則

<rule name="redirect Root Domain" stopProcessing="true"> 
    <match url="^$" /> 
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> 
     <add input="{HTTP_HOST}" pattern="^(www.)?windshield-replacement-cost\.org$" /> 
    </conditions> 
    <action type="Redirect" url="http://replacement-cost.net/windshield-replacement-cost" /> 
</rule> 

此之前添加新的規則是你的現有規則

<rule name="redirectDomain" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAny" trackAllCaptures="false"> 
     <add input="{HTTP_HOST}" pattern="^(www.)?windshield-replacement-cost\.org$" /> 
    </conditions> 
    <action type="Redirect" url="http://replacement-cost.net/{R:1}" redirectType="Permanent" /> 
</rule> 
+0

完美 - 你的先生是一個傳奇! – loveforfire33 2012-04-27 00:29:23