【发布时间】:2015-04-22 16:43:52
【问题描述】:
我想为所有 php、htm、html 页面自动添加 X-Robots-Tag 标头,/index.php 和 forgot.php 除外。
这将涵盖所有这些:
<FilesMatch "\.(htm|html|php)$">
<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex, nofollow"
</IfModule>
</FilesMatch>
但是我怎样才能从 FilesMatch 指令中排除 /index.php 和 /forgot.php?
我想要它做什么:
适用于所有 .htm、.html、.php 文件
排除/index.(htm|html|php)、/forgot.(htm|html|php),但不是*/index.php应该是有效的。
希望这是有道理的...我只想将其从站点底部的这两个特定文件中排除。
更新: 在tester 上玩这个,但仍然有一些问题:
(?!.*/(index.php|forgot))(^.*\.(php|htm|html)$)
这不包括像 www.mysite.com/folder/index.php 这样的 URL
【问题讨论】:
标签: .htaccess