在谷歌重复的内容。 htaccess的或robots.txt的? [英] Duplicated content on google. htaccess or robots.txt?

查看:134
本文介绍了在谷歌重复的内容。 htaccess的或robots.txt的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站我有以下几类URL结构:

/category.php?id=6 (ID = 6是互联网类)

我的搜索引擎友好的URL是这样的:

  /分类/ 6 /互联网/
 

问题是,它可以在任何这些形式进行访问,正因为如此,我越来越对谷歌重复的内容。

所以,我想知道我怎么能解决这个问题。

我应该禁止对的robots.txt 它与的任何网址?

如果是这样,我怎么能正确地设置?

我应该做一个重定向永久移动关于的.htaccess

如果是这样,我怎么能正确地设置?

我的实际的.htaccess 的类别是这样的:

 重写规则^类/([^ /] *)/([^ /] *)1 / $ category.php ID = $&放大器;名称= $ 2 [L]
 

解决方案

您只需要设置规范链接标签在你的页面头部

看的http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html

http://support.google.com /webmasters/bin/answer.py?hl=en&answer=139394

这看起来像

 <链接REL =规范的href =htt​​p://www.example.com/category/6/internet//>
 

6类网页

您也可以做301重定向在您的.htaccess中的category.php页面中加入

 重写规则^ category.php ID =([^&放大器;] *)及名称=([^&放大器;] *)/分类/ $ 1 / $ 2 / [R = 301,L]
 

如果你不想去的RewriteRules的路线,你可以把下面的code在config.php文件的顶部:

 如果(preg_match('/ ^ \ /配置\的.php /',$ _ SERVER ['REQUEST_URI'])){
    标题(HTTP / 1.1 301永久移动);
    标题(位置:/分类/ {$ _ GET ['身份证']} / {$ _ GET ['名称']});
    死();
}
 

无论哪种方式,取决于你,但我会用重写规则选项重定向到我的搜索引擎友好的URL如果我是你,

In my website I have the following categories url structure:

/category.php?id=6 (id=6 is for internet category)

My SEO friendly url is like:

/category/6/internet/

The problem is it can be accessed in any of those forms, and because of that, I'm getting duplicate content on google.

So, I'm wondering how can I fix that.

Should I disallow on robots.txt any urls with ? on it?

If so, how can I properly set it up?

Should I make a redirection "Permanently Moved" on .htaccess?

If so, how can I properly set it up?

My actual .htaccess for categories is like this:

RewriteRule ^category/([^/]*)/([^/]*)/$ category.php?id=$1&name=$2 [L]

解决方案

You just need to set the canonical link tag in the head section of your pages

see http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html

and http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394

It will look something like

<link rel="canonical" href="http://www.example.com/category/6/internet/"/>

on the category 6 page

You could also do a 301 redirect for the category.php pages in your .htaccess by adding

RewriteRule ^category.php?id=([^&]*)&name=([^&]*) /category/$1/$2/ [R=301,L]

If you didn't want to go the route of rewriterules you could put the following code at the top of config.php:

if(preg_match('/^\/config\.php/', $_SERVER['REQUEST_URI'])){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: /category/{$_GET['id']}/{$_GET['name']}");
    die();
}

Either way is up to you but I would use the rewriterule option to redirect to my SEO friendly URL If I were you

这篇关于在谷歌重复的内容。 htaccess的或robots.txt的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆