[提问]
关于GD WINDOWS的web.config做301重定向的问题
|
|
关于GD WINDOWS的web.config做301重定向的问题
如下代码,将baidu.com定向到www.baidu.com。
那假如我还有baidu.cn和www.baidu.cn,也要定向到www.baidu.com,完整代码应该是什么呢?我改了很久,都不行,不是500错误,就是(3个之中)只有第一个能301定向,另两个则无法定向!
谢谢!- <configuration>
- <system.webServer>
- <httpErrors errorMode="Detailed" />
- <asp scriptErrorSentToBrowser="true"/>
- <rewrite>
- <rules>
- <rule name="WWW Redirect" stopProcessing="true">
- <match url=".*" />
- <conditions>
- <add input="{HTTP_HOST}" pattern="^baidu.com$" />
- </conditions>
- <action type="Redirect" url="http://www.baidu.com/{R:0}"
- redirectType="Permanent" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
- <system.web>
- <customErrors mode="Off"/>
- <compilation debug="true"/>
- </system.web>
- </configuration>
复制代码 |
|
|
|
|
|
|
|
|
|
|
打酱油
发表于 2011-2-15 01:32:28
|
显示全部楼层
- <conditions>
- <add input="{HTTP_HOST}" pattern="^baidu.com$" />
- <add input="{HTTP_HOST}" pattern="^baidu.cn$" />
- <add input="{HTTP_HOST}" pattern="^www.baidu.cn$" />
- </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 发表 
我有这样试过,不行。。。
抱歉 我脑残了 应该是这样的- <conditions>
- <add input="{HTTP_HOST}" pattern="^(baidu\.com|baidu\.cn|www\.baidu\.cn)$" />
- </conditions>
复制代码 还是不行的话吧复制多几个<rule></rule> 分别修改 注意 name要不同 比如- <configuration>
- <system.webServer>
- <rules>
- <rule name="WWW Redirect1" stopProcessing="true">
- <match url=".*" />
- <conditions>
- <add input="{HTTP_HOST}" pattern="^baidu.com$" />
- </conditions>
- <action type="Redirect" url="http://www.baidu.com/{R:0}" redirectType="Permanent" />
- </rule>
- <rule name="WWW Redirect2" stopProcessing="true">
- <match url=".*" />
- <conditions>
- <add input="{HTTP_HOST}" pattern="^baidu.cn$" />
- </conditions>
- <action type="Redirect" url="http://www.baidu.com/{R:0}" redirectType="Permanent" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
- </configuration>
复制代码 |
|
|
|
|
|
|
|
|
|
|
fgl31
发表于 2011-2-27 19:26:01
|
显示全部楼层
正需要这个,来看一下。
我现在的问题。想把52simk.com和www.52simk.com定向到www.52simk.cn。不要动52simk.cn,因为怕动这个影响收录,网站已经快两年了,我现在才发现这问题 |
|
|
|
|
|
|
|
|