2016-05-16 98 views
0

我有一個網站,我打算關閉並用另一個域替換另一個網站,我如何去設置301重定向從我的舊網站上的特定頁面到我新的相關頁面?從asp.net網站創建301重定向到另一個

我看了一下IIS Url Rewrite模塊,但無法弄清楚。請幫助?

我已經試過這

<rewrite> 
    <rules> 
     <rule name="Redirects to new domain" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions logicalGrouping="MatchAny"> 
      <add input="{HTTP_HOST}" pattern="http://domain.com/" /> 
      </conditions> 
      <action type="Redirect" url="http://www.domain.com/{R:0}" /> 
     </rule> 
    </rules> 
</rewrite> 

但沒有任何反應,當導航到主頁

回答

0

你可以用這樣的路由規則更新你的web.config:

<system.webServer> 
    <rewrite> 
    <rules> 
     <rule name="Redirects to new domain" stopProcessing="true"> 
     <match url=".*" /> 
     <conditions logicalGrouping="MatchAny"> 
      <add input="{HTTP_HOST}" pattern="olddomain.net" /> 
     </conditions> 
     <action type="Redirect" url="http://www.newdomain.com/{R:0}" /> 
     </rule> 
    </rules> 
    </rewrite> 
</system.webServer> 
+0

它不工作。請參閱編輯問題 – Bob

+0

您在HTTP_HOST的條件模式中有http://,您應該只有一個域名,例如「domain.com」,沒有http或https,因爲它不是主機名的一部分。 –