使依赖于 GET 参数的 PHP 页面对搜索引擎友好

发布于 2024-11-14 04:25:28 字数 457 浏览 5 评论 0原文

假设某个网站上有一篇关于体育的文章“科比·布莱恩特是最好的”

1) 它对谷歌爬虫有影响吗?为了获得高搜索相关性,无论该文章是否在此页面上:

a)    www.sitename.com/sports.php?typeid=1&tid=3

或在此页面上:

  b)  www.sitename.com/sports.php?type=basketball&topic=KobeBryant is the best

或者在这个

 c)  www.sitename.com/sports/basketball/KobeBryantisthebest

2)我熟悉如何实现(a)和(b)似乎是一个简单的扩展。如何实现如 (c) 所示的 URL 格式?

谢谢

Say there is an article on a site about sports "Kobe Bryant is the best"

1) Does it make a difference to the google crawler, and for purposes of attaining a high search relevance whether that article is on this page:

a)    www.sitename.com/sports.php?typeid=1&tid=3

OR on this one:

  b)  www.sitename.com/sports.php?type=basketball&topic=KobeBryant is the best

OR on this one

 c)  www.sitename.com/sports/basketball/KobeBryantisthebest

2) I am familiar with how to achieve (a) and (b) seems like a straightforward extension. How does one achieve a URL format like in (c)?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

青瓷清茶倾城歌 2024-11-21 04:25:28

您需要创建一个 .htaccess 文件...

代码必须类似于:

Options +FollowSymLinks   
RewriteEngine On   

RewriteCond %{SCRIPT_FILENAME} !-d   
RewriteCond %{SCRIPT_FILENAME} !-f   

RewriteRule ^sports/([-a-z]+)*/([a-z-A-Z]+)*/$ ./sports.php?type=$1&topic=$2

这将重写 url,以便通过以下方式访问:

www.sitename.com/sports/basketball/KobeBryantisthebest

如果您复制并粘贴代码,只要有一个名为 sports.php 的页面并且 PHP 代码将 $_GET['type'] 并会 $_GET[' ,它就应该可以工作。 topic']

希望这有帮助

You will need to create a .htaccess file...

The code will have to be something like:

Options +FollowSymLinks   
RewriteEngine On   

RewriteCond %{SCRIPT_FILENAME} !-d   
RewriteCond %{SCRIPT_FILENAME} !-f   

RewriteRule ^sports/([-a-z]+)*/([a-z-A-Z]+)*/$ ./sports.php?type=$1&topic=$2

This will rewrite the url so that is accessed by:

www.sitename.com/sports/basketball/KobeBryantisthebest

If you copy and paste the code it should just work as long as there is a page called sports.php and the PHP code will $_GET['type'] and wil $_GET['topic']

Hope this helps

一抹淡然 2024-11-21 04:25:28

对于第一个问题,我认为这个会更好:
www.sitename.com/sports/basketball/Kobe-Bryant-is-the-best

For the first question, I think this one would be better:
www.sitename.com/sports/basketball/Kobe-Bryant-is-the-best

爱格式化 2024-11-21 04:25:28

由于问题2)已经被swenflea很好地回答了,我不会再处理这个问题了。

至于问题 1):在搜索引擎优化 (SEO) 方面,a) 和 b)+c) 之间显然存在差异,因为在 URL a) 中没有给出与给定搜索查询相匹配的关键字(而是有是 ID)。至于b)和c),如果有人搜索“篮球”,谷歌就会把你的URL作为网站评级的标准。在 b) 和 c) 中,它会在 URL 中找到“篮球”一词,并将您的结果在 SERP 中向上移动一点,但在 a) 中,它找不到“篮球”,因此您的 URL 不会为您提供帮助。

还有研究表明,人类更喜欢可阅读的 URL,这意味着能够在重定向到 www.sitename1.com/sports.php?typeid=1&tid=3 的 URL 之间进行选择和 www.sitename2.com/sports/basketball/Kobe-Bryant-is-the-best(参见 Kemal Fadillah),更多人会选择 sitename2。然而,我不得不承认,我不知道有多少人真正检查结果的 URL ;)

在比较 b) 和 c) 时,我不知道 Google 是否会有差异。如果您改变参数,某些爬虫可能会遇到问题,因为会有两个不同的 URL:

  • www.sitename.com/sports.php?type=basketball&topic=KobeBryant is the best
  • www.sitename.com/sports.php?topic=KobeBryant is the best&type=basketball

我认为 Google 确实将它们识别为同一网站,但我不知道他们是否会给予相同的排名就好像您实际上只使用了一个 URL。过去,人们也经常谈论搜索引擎不会对 URI 的查询部分进行如此高的评价(查询部分=之后的部分?),但我认为 Google 已经否认了这一点。然而,这又对人类产生了心理影响,他们喜欢没有“神秘”字符的 URL,例如 ?&= 等。

因此,对于 SEO,您仍然会遇到这样的问题:在调整参数时,同一网站可能有多个 URL。对于人类来说,你会产生心理影响。

为什么 c) 并不完美,而 Kemal Fadillahs 的解决方案更好,在 Kemal Fadillahs 答案下面的评论中进行了解释。

As question 2) has already been answered very well by swenflea, I will not deal with that anymore.

As for question 1): There clearly is a difference between a) and b)+c) with regards to search engine optimization (SEO), because in URL a) there are no keywords given that would match the given search query (instead there are IDs). As for b) and c) if somebody searches “basketball” Google would take your URL as a criterion for rating the website. In b) and c) it will find the word “basketball” in the URL and move your result a bit upwards in the SERPs, but in a) it cannot find “basketball”, so your URL won’t help you there.

There have also been researches on that humans prefer URLs which they can read, meaning that being able to choose between a URL redirecting to www.sitename1.com/sports.php?typeid=1&tid=3 and www.sitename2.com/sports/basketball/Kobe-Bryant-is-the-best (cf. Kemal Fadillah), more people would choose sitename2. Yet, I have to admit, I do not know how many people really check the URL of a result ;)

When comparing b) and c) I do not know if there would be a difference for Google. You could hit problems with some crawlers if you turn the parameters around as there would be two different URLs:

  • www.sitename.com/sports.php?type=basketball&topic=KobeBryant is the best
  • www.sitename.com/sports.php?topic=KobeBryant is the best&type=basketball

I think Google does recognize them as the same site, but I do not know if they will give it the same rank as if you really only used one URL. In the past, people also talked a lot about that search engines do not rate the query part of a URI that high (query part = parts after ?), but I think that one has been disclaimed by Google. Yet, there is again a psychological effect for humans, who like the URL without “cryptic” characters like ?, & and = more.

So as for SEO you would remain with the problem that there might be multiple URLs for the same website when turning parameters around. As for humans you have the psychological effect.

Why c) is not perfect and Kemal Fadillahs solution is better is explained in the comment below Kemal Fadillahs answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文