【问题标题】:Need to block subdomain using robots.txt which is on same directory level需要使用同一目录级别的 robots.txt 阻止子域
【发布时间】:2014-11-13 18:15:53
【问题描述】:

我有一个问题

我有域名,例如 www.testing.comnew.testing.com,所以我不想在任何搜索引擎中显示 new.testing.com。我在 new.testing.com 中添加了一个 robots.txt。并且两个站点都有相同的父目录

--httpdoc
----testing.com
----new.testing.com

所以我想知道我可以使用 testing.com 的一个 robots.txt 处理两个站点吗?有可能吗???

如果可能,请给我建议解决方案。

【问题讨论】:

    标签: seo robots.txt


    【解决方案1】:

    遵循内部规则对我有用,

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^subdomain\.maindomain\.com$ [NC]
    RewriteRule ^/robots.txt$ /nobots.txt [L]
    

    并将'nobots.txt'添加到根目录,如下所示,

    User-agent: *
    Disallow: / 
    

    【讨论】:

      【解决方案2】:
      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^subdomain.website.com$
      RewriteRule ^robots\.txt$ robots-subdomain.txt
      

      然后将以下内容添加到/robots-subdomain.txt:

      User-agent: *
      Disallow: / 
      

      【讨论】:

      • 正是我想要的。谢谢!
      【解决方案3】:

      您可以做的最好的事情是添加单独的 robots.txt 文件。在每个目录中放置一个。你应该有

      • testing.com/robots.txt 和
      • new.testing.com/robots.txt

      将 robots.txt 文件添加到 new.testing.com 后,您应该添加以下代码以使搜索引擎远离。

      User-agent: *
      Disallow: /
      

      【讨论】:

      • 如果域和子域在同一个目录,如何只允许子域?不允许:/new.domain.com/ 那是真的吗?还是有其他想法?请帮忙...
      猜你喜欢
      • 2015-01-19
      • 2013-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多