301重定向进行URL标准化设置

301重定向进行URL标准化设置

经常会碰到这样的情况,其他网站链接你的站点时,会用下面的链接:

www.beimingfish.com
beimingfish.com
www.beimingfish.com/index.php
beimingfish.com/index.php

而这样导致:你站点主域名的pr值分散到其他几个URLs了。

如果你用301重定向把其他URL转到
www.beimingfish.com
PR也就集中在主域名:www.beimingfish.com
了。

301重定向具体办法:

设置.htaccess文件(只适用于linux系统,并需要虚拟主机支持。)

使访问beimingfish.com的时候就会自动转到www.beimingfish.com
在.htaccess文件里写上以下代码即可。

RewriteEngine on
RewriteCond %{http_host} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

注意:URL标准化的301重定向(以上代码)需要写在其他URL-rewrite代码之前。

Share this post

发表评论