不同的域名,不同的语言,相同的内容,1 robots.txt

时间:2015-02-14 07:13:18

标签: robots.txt

我遇到这种情况:

域:

www.example.com
www.example.it

指向不同语言的相同内容。 E.g:

www.example.com/audi-car.html
www.example.it/audi-auto.html

我在根域中只有只有一个robots.txt

我的问题是:如何设置我的robots.txt以禁止将www.example.it抓取到来自www.example.com并反转的所有机器人?

1 个答案:

答案 0 :(得分:0)

为每个域编写不同的robots.txt,并使用.htaccess根据请求来自的主机重定向robots.txt请求:

    RewriteCond %{HTTP_HOST} ^(.*)\.com$ [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^robots\.txt$  /robots-com.txt [L]

    RewriteCond %{HTTP_HOST} ^(.*)\.it$ [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^robots\.txt$  /robots-it.txt [L]

确保RewriteEngine On置于顶部并启用mod_rewrite。

相关问题