Eri*_*ric 8 .htaccess mod-rewrite robots.txt web-crawler google-webmaster-tools
我有:
我希望domain.com被搜索引擎抓取并编入索引,但不是testing.domain.com
测试域和主域共享相同的SVN存储库,因此我不确定单独的robots.txt文件是否可行...
Laz*_*One 11
1)创建单独的robots.txt文件(例如,将其命名为robots_testing.txt).
2)将此规则添加到网站根文件夹中的.htaccess:
RewriteCond %{HTTP_HOST} =testing.example.com
RewriteRule ^robots\.txt$ /robots_testing.txt [L]
Run Code Online (Sandbox Code Playgroud)
它将重写(内部重定向)robots.txt对robots_testing.txtIF域名=的任何请求testing.example.com.
另外,做相反的-重写所有请求robots.txt,以robots_disabled.txt除外的所有域example.com:
RewriteCond %{HTTP_HOST} !=example.com
RewriteRule ^robots\.txt$ /robots_disabled.txt [L]
Run Code Online (Sandbox Code Playgroud)