2016-05-16 117 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,因为它不是主机名的一部分。 –