V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Chalice
V2EX  ›  WordPress

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

  •  
  •   Chalice · 2016-11-21 04:33:12 +08:00 · 2538 次点击
    这是一个创建于 2706 天前的主题,其中的信息可能已经有所发展或是发生改变。
    User-agent: *
    Allow: /index.php
    Disallow:/
    我的做法是这样,请问正确吗?
    5 条回复    2016-11-24 00:16:13 +08:00
    justyy
        1
    justyy  
       2016-11-21 07:34:42 +08:00   ❤️ 1
    不要用 robots.txt!!!!
    不要用 robots.txt!!!!
    不要用 robots.txt!!!!




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

    <?php
    if (!is_home()) {// 除了首页
    ?>
    <meta name=robots content='noindex, follow'>
    <?php
    }
    ??
    Chalice
        2
    Chalice  
    OP
       2016-11-21 11:19:06 +08:00
    谢谢,顺便请问下不用 robots.txt 的原因是因为对搜索引擎不如 meta 友好吗?
    justyy
        3
    justyy  
       2016-11-21 17:39:25 +08:00   ❤️ 1
    @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
        4
    hqfzone  
       2016-11-22 16:00:15 +08:00   ❤️ 1
    User-agent: *
    Disallow: /
    Allow: /$
    亲测百度等可以,你写的那个收录的是 index.php ,好丑。
    Chalice
        5
    Chalice  
    OP
       2016-11-24 00:16:13 +08:00
    @justyy 明白了,十分感谢!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5668 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 02:32 · PVG 10:32 · LAX 19:32 · JFK 22:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.