重定向到 .htaccess 中的不同域特定 robots_(blue|pink).txt:
<IfModule mod_write.c>
RewriteEngine on
# internal redirect to robots_blue.txt
RewriteCond %{HTTP_HOST} =www.blue.com
RewriteRule ^robots\.txt$ /robots_blue.txt [L]
# internal redirect to robots_pink.txt
RewriteCond %{HTTP_HOST} =www.pink.com
RewriteRule ^robots\.txt$ /robots_pink.txt [L]
# internal redirct to index_blue.php, rewrite internal only
RewriteCond %{HTTP_HOST} =www.blue.com
RewriteRule ^index\.php$ /index_blue.php [L] # or "... /index.php?site=blue"
# external permanent redirect of test.php to index.php if not www.blue.com
RewriteCond %{HTTP_HOST} !=www.blue.com
RewriteRule ^test\.php$ /index.php [L,R=301]
# internal redirect
RewriteCond %{HTTP_HOST} =www.pink.com
RewriteRule ^index\.php$ /index_pink.php [L]
robots_blue.txt,不要抓取 www.blue.com 中的 test.php:
User-agent: *
Sitemap: http://www.blue.com/sitemap.xml
Disallow: /test.php
Disallow: ...
robots_pink.txt,在 www.pink.com 中允许抓取:
User-agent: *
Sitemap: http://www.blue.com/sitemap.xml
Disallow:
如果 www.blue.com 的 Disallows 与 www.pink.com 相同,则只需将 robots_blue.txt 用作两个域的 robots.txt。如果 www.pink.com 中没有使用 test.php,它应该可以工作。
但是,如果在 robots.txt 中也使用 sitemap.xml,这应该是一个解决方案。