【发布时间】:2012-11-01 14:49:24
【问题描述】:
我可以在 .htaccess 中使用 x 机器人“noindex,follow”特定页面吗?
我找到了一些关于 noindexing 类型文件的说明,但是我找不到 noindex 单个页面的说明,并且到目前为止我尝试过的方法没有奏效。
这是我要查找的页面 noindex:
http://www.examplesite.com.au/index.php?route=news/headlines
这是我迄今为止尝试过的:
<FilesMatch "/index.php?route=news/headlines$">
Header set X-Robots-Tag "noindex, follow"
</FilesMatch>
感谢您的宝贵时间。
【问题讨论】:
-
FilesMatch参数是一个正则表达式,因此您可能必须“转义”一些特殊字符,例如.和?。我现在无法测试,但我想测试"/index\.php\?route=news/headlines$"。 -
在 PHP 中处理这种情况要比在
.htaccess中容易得多;你不能直接调用header('X-Robots-Tag: noindex, follow'),可能在news控制器中的headlines操作中(如果这确实是一个MVC 架构)?
标签: .htaccess http-headers nofollow noindex x-robots-tag