Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

.Htaccess 域名301跳转错误

今天发现一个网站不带www的域名,被Google收录的大两页面,大家都知道,这是个比较严重的问题,因为新收录的页面会和带www的域名下的页面重复,影响原来页面的排名。

于是根据301 跳转规则,写了下面的代码,追加到 .htaccess里面:
RewriteCond %{HTTP_HOST} ^jarfee.cn [NC]
RewriteRule ^(.*)$ http://www.jarfee.cn/$1 [L,R=301]
测试后发现,跳转是跳转了,却跳到了动态的URL上。比如:
http://jarfee.cn/goods-33.html 跳转到了 http://www.jarfee.cn/goods.php?id=33
本来应该跳转到:http://www.jarfee.cn/goods-33.html 。。。

来来回回测试了好多遍,都不行,问题出在哪里了?

仔细研究了.htaccess后,发现,里面有很多重写规则,包括 goods 的,会不会是先执行了这些规则?

于是,把上面的跳转代码,写在.htaccess最上面,也就是紧接着
RewriteEngine On
Options +FollowSymLinks
写,搞定。

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>