可以重写robots.txt
到其他的文件(让我们命名含有这种 'robots_no.txt':
User-Agent: *
Disallow:/
(来源:http://www.robotstxt.org/robotstxt.html)
的.htaccess文件看起来像这样:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^robots.txt$ robots_no.txt
使用customiz编辑robots.txt的每个(子)域:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [OR]
RewriteCond %{HTTP_HOST} ^sub.example.com$ [OR]
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.org$ [OR]
RewriteCond %{HTTP_HOST} ^example.org$
# Rewrites the above (sub)domains <domain> to robots_<domain>.txt
# example.org -> robots_example.org.txt
RewriteRule ^robots.txt$ robots_${HTTP_HOST}.txt [L]
# in all other cases, use default 'robots.txt'
RewriteRule ^robots.txt$ - [L]
不要问搜索引擎阻止超过www.example.com
其他网页上的所有网页,你可以使用<link rel="canonical">
了。
如果http://example.com/page.html
和http://example.org/~example/page.html
都指向http://www.example.com/page.html
,把下一个标签在<head>
:
<link rel="canonical" href="http://www.example.com/page.html">
参见Googles article about rel="canonical"
Lekensteyn,看起来不错。但是,我有一个小小的怀疑。是否有可能根据url分配不同的robot.txt文件。无法找到这样的规则。如果你能指点我这样的馅饼,这将是有益的..感谢.. – 2010-10-06 03:49:17
你是什么意思'基于URL'?如果你的意思是'域名',看看上面的例子。重写指南:http://httpd.apache.org/docs/current/rewrite/rewrite_intro.html。为每个域实现不同的'robots.txt'的另一种方式是使用serverscript,例如PHP。 – Lekensteyn 2010-10-06 07:21:44
gotchas .. thankees ..! – 2010-10-07 09:10:50