Windows虚拟主机设置301重定向

使用301重定向 seoanyi.com 到www.seoanyi.com 可以防止网站流量的分流,优化网页收录,有利于网页PR传递,等等。
在godaddy的linux主机上进行301重定向是很简单的,只需要修改主机.htaccess文件即可。
RewriteEngine on
RewriteRule ^(.*)$ https://www.williamlong.info/$1 [R=301,L]
但是很多人对在godaddy的windows虚拟主机中进行301 重定向却很陌生。介绍一种GODADDY的Windows主机下,seoanyi.com通过301重定向到 www.seoanyi.com的方法。该方法在godaddy的windows虚拟主机中实现起来非常便捷。当然前提条件就 是:windows主机是IIS7.0或以上的版本。

方法如下:
在网站的根目录下新建web.config文件并将一下代码加入到文件中。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<configuration>
<system .webServer>
<rewrite>
<rules>
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^seoanyi.com$" />
</conditions>
<action type="Redirect" url="https://www.seoanyi.com/{R:0}" 
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system>
</configuration>

如果你的网站已经有了web.config文件。修改你的web.config文件。在web.config文件… 中的最后一行后面添加以下代码:

1
2
3
4
5
6
7
8
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^seoanyi.com$" />
</conditions>
<action type="Redirect" url="https://www.seoanyi.com/{R:0}" 
redirectType="Permanent" />
</rule>

最后需要提醒的是在添加或者修改web.config时,别忘了把我的域名btbuzz.com修改成所要跳转的域名。
一个很重要事就是要使用“Permanent”(永久)定向。这样做很有帮助的是,任何人链接你的网站是使用的非www地址时,直接使搜索引擎的机器人在抓取作为永久移动的链接。新的url将会被定义为正确的地址,因此旧的非www地址将不会被索引。
一棵树认为:把网站域名(带www和非www)301重定向(资源永久重定向)到某一个域名(如上面案例,把非www地址永久重定向到带www上,有助于网站SEO优化,欢迎批评或参考。
当然在windows主机中实现301 重定向的方法还有很多很多。比如 ISAPI Rewrite实现301重定向,根据网站语言类型(php,asp,asp.net,etc)在网页头文件中添加跳转语句,根据网站CMS添加插件或者代码.

样例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<system.webServer>
<directoryBrowse enabled="false" />
<defaultDocument>
<files>
<clear />
<add value="Default.html" />
<add value="index.aspx" />
<add value="index.php" />
<add value="index.asp" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="default.aspx" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="park.htm" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^seoanyi.com$" />
</conditions>
<action type="Redirect" url="https://www.seoanyi.com/{R:0}" 
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

1 Star2 Stars3 Stars4 Stars5 Stars (无评分)
Loading...

在线客服

QQ客服

微信客服