分享

写回答

发帖

[提问] 关于GD WINDOWS的web.config做301重定向的问题

GoDaddy GoDaddy 2315 人阅读 | 6 人回复

发表于 2011-2-15 01:12:40 | 显示全部楼层 |阅读模式

关于GD WINDOWS的web.config做301重定向的问题
如下代码,将baidu.com定向到www.baidu.com。
那假如我还有baidu.cn和www.baidu.cn,也要定向到www.baidu.com,完整代码应该是什么呢?我改了很久,都不行,不是500错误,就是(3个之中)只有第一个能301定向,另两个则无法定向!
谢谢!
  1. <configuration>
  2.     <system.webServer>
  3.         <httpErrors errorMode="Detailed" />
  4.         <asp scriptErrorSentToBrowser="true"/>
  5.                 <rewrite>   
  6.      <rules>      
  7.       <rule name="WWW Redirect" stopProcessing="true">      
  8.         <match url=".*" />         
  9.         <conditions>         
  10.           <add input="{HTTP_HOST}" pattern="^baidu.com$" />
  11.         </conditions>      
  12.         <action type="Redirect" url="http://www.baidu.com/{R:0}"        
  13.            redirectType="Permanent" />      
  14.      </rule>   
  15.      </rules>   
  16.    </rewrite>
  17.     </system.webServer>
  18.     <system.web>
  19.         <customErrors mode="Off"/>
  20.         <compilation debug="true"/>
  21.     </system.web>
  22. </configuration>
复制代码

回答|共 6 个

打酱油

发表于 2011-2-15 01:32:28 | 显示全部楼层

  1.         <conditions>         
  2.           <add input="{HTTP_HOST}" pattern="^baidu.com$" />
  3.           <add input="{HTTP_HOST}" pattern="^baidu.cn$" />
  4.           <add input="{HTTP_HOST}" pattern="^www.baidu.cn$" />
  5.         </conditions>      
复制代码
没有多个域名 未测试

wkl17

发表于 2011-2-20 00:03:42 | 显示全部楼层

原帖由 打酱油 于 2011-2-15 01:32 AM 发表
                  
         
         
         
              没有多个域名 未测试

我有这样试过,不行。。。

fxin

发表于 2011-2-20 01:00:08 | 显示全部楼层

给你个正确的 xxx.com转www.xxx.com 配置:

<configuration>
    <system.webServer>
<rewrite>
   <rules>
    <rule name="WWW Redirect" stopProcessing="true">
     <match url=".*" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="^123.com$" />
     </conditions>
     <action type="Redirect" url="http://www.123.com/{R:0}"  redirectType="Permanent" />
    </rule>  
   </rules>
  </rewrite>
    </system.webServer>
</configuration>

wkl17

发表于 2011-2-20 13:35:58 | 显示全部楼层

原帖由 fxin 于 2011-2-20 01:00 AM 发表
给你个正确的 xxx.com转www.xxx.com 配置:


   
  
   
     
      
      
      
      
      
      
   
   
   

谢谢!但不知道假如有多个域名要301定向,应该如何呢?谢谢!

打酱油

发表于 2011-2-26 05:42:10 | 显示全部楼层

原帖由 wkl17 于 2011-2-20 12:03 AM 发表

我有这样试过,不行。。。


抱歉 我脑残了 应该是这样的
  1.         <conditions>         
  2.           <add input="{HTTP_HOST}" pattern="^(baidu\.com|baidu\.cn|www\.baidu\.cn)$" />
  3.         </conditions>
复制代码
还是不行的话吧复制多几个<rule></rule> 分别修改 注意 name要不同 比如
  1. <configuration>
  2.     <system.webServer>
  3.      <rules>
  4.       <rule name="WWW Redirect1" stopProcessing="true">
  5.         <match url=".*" />
  6.         <conditions>
  7.           <add input="{HTTP_HOST}" pattern="^baidu.com$" />
  8.         </conditions>
  9.         <action type="Redirect" url="http://www.baidu.com/{R:0}" redirectType="Permanent" />
  10.      </rule>
  11.       <rule name="WWW Redirect2" stopProcessing="true">
  12.         <match url=".*" />
  13.         <conditions>
  14.           <add input="{HTTP_HOST}" pattern="^baidu.cn$" />
  15.         </conditions>
  16.         <action type="Redirect" url="http://www.baidu.com/{R:0}" redirectType="Permanent" />
  17.      </rule>
  18.      </rules>
  19.    </rewrite>
  20.     </system.webServer>
  21. </configuration>
复制代码

fgl31

发表于 2011-2-27 19:26:01 | 显示全部楼层

正需要这个,来看一下。
我现在的问题。想把52simk.com和www.52simk.com定向到www.52simk.cn。不要动52simk.cn,因为怕动这个影响收录,网站已经快两年了,我现在才发现这问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则