Wordpress 如何让搜索引擎只收录首页?

2016-11-21 04:33:12 +08:00
 Chalice
User-agent: *
Allow: /index.php
Disallow:/
我的做法是这样,请问正确吗?
2542 次点击
所在节点    WordPress
5 条回复
justyy
2016-11-21 07:34:42 +08:00
不要用 robots.txt!!!!
不要用 robots.txt!!!!
不要用 robots.txt!!!!




在 header.php 里 判断 是否是首页

<?php
if (!is_home()) {// 除了首页
?>
<meta name=robots content='noindex, follow'>
<?php
}
??
Chalice
2016-11-21 11:19:06 +08:00
谢谢,顺便请问下不用 robots.txt 的原因是因为对搜索引擎不如 meta 友好吗?
justyy
2016-11-21 17:39:25 +08:00
@Chalice
如果 你有一个页面 , 已经在搜索引擎里了, 后来你决定不让搜索引擎 索引该页面,
如果你用 robots.txt 禁止,那么搜索引擎是无法访问该页面的,也就是说它并不知道你是否让它索引,即使你在该 页面里加入 noindex 也是没用的。

https://moz.com/learn/seo/robotstxt

Block with Robots.txt
This tells the engines not to crawl the given URL, but that they may keep the page in the index and display it in in results. (See image of Google results page below.)

Block with Meta NoIndex
This tells engines they can visit, but are not allowed to display the URL in results. This is the recommended method.
hqfzone
2016-11-22 16:00:15 +08:00
User-agent: *
Disallow: /
Allow: /$
亲测百度等可以,你写的那个收录的是 index.php ,好丑。
Chalice
2016-11-24 00:16:13 +08:00
@justyy 明白了,十分感谢!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/321966

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX