同样是深山的一个新站honsehuoxian.com,很久不收录一个内页,但是今天意外的发现早上发的文章下午就收录了,但是我是www域名定向到不带www的域名,它收录的这个网页带www我肯定就不乐意了,我得想办法给它做个301才是。如下图收录的是带www的内页,点进去也是一样的带了www
同域名下的内页如何做301跳转同域名下的内页如何做301跳转
我是Linux系统,是php语言的(如果一下方法你不适用,请忽略我的文章),我们可以利用.htaccess文件来实现内页的跳转,
就以http://www.honsehuoxian.com/zaoyin/99.html
跳转到http://honsehuoxian.com/zaoyin/99.html为例
新建一个记事本文件夹,重命名为.htaccess文件(注意没有txt的后缀),在.htaccess中填入如下代码:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.honsehuoxian.com$
RewriteRule ^zaoyin/99.html$ http://honsehuoxian.com/zaoyin/99.html [R=301,L]
然后上传到网站的根目录,刷新一下,骚等几秒钟或者清除浏览器缓存,再来看看效果,是否可以完全跳转了?
同域名下的内页如何做301跳转
如果你有N多个内页需要做301怎么办呢?如下
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.honsehuoxian.com$
RewriteRule ^zaoyin/99.html$ http://honsehuoxian.com/zaoyin/99.html [R=301,L]
RewriteRule ^product/gyz/$ http://honsehuoxian.com/zaoyin/product/gyz/ [R=301,L]
RewriteRule ^news/hyxw/556.html$ http://honsehuoxian.com/zaoyin/news/hyxw/556.html [R=301,L]
如果说上面这种方法不行(可以跳转但是不会返回404状态码),那么你还有写嘛这种写法可选择,同样是写到.htaccess里面
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.honsehuoxian.com$
RewriteRule ^product/geyinban/574.html$ http://honsehuoxian.com/product/geyinban/574.html [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.honsehuoxian.com$
RewriteRule ^case/488.html$ http://honsehuoxian.com/case/488.html [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.honsehuoxian.com$
RewriteRule ^case/493.html$ http://honsehuoxian.com/case/493.html [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.honsehuoxian.com$
RewriteRule ^news/qydt/442.html$ http://honsehuoxian.com/news/qydt/442.html [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.honsehuoxian.com$
RewriteRule ^news/hyxw/471.html$ http://honsehuoxian.com/news/hyxw/471.html [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.honsehuoxian.com$
RewriteRule ^news/list_1_4.html$ http://honsehuoxian.com/news/list_1_4.html [R=301,L]
还没有评论,来说两句吧...