2012-01-10 30 views
3

是否可以使用apache .htaccess基於URL查詢字符串應用HTTP標頭指令?如何根據URL查詢字符串通過.htaccess文件設置X-Robots-Tag HTTP標頭

例如,在此基礎上的資源http://code.google.com/web/controlcrawlindex/docs/robots_meta_tag.html下標題爲「實際實現X-Robots-Tag中與阿帕奇」一節,它說下面的.htaccess文件的指令可用於:

<Files ~ "\.pdf$"> 
    Header set X-Robots-Tag "noindex, nofollow" 
</Files> 

我尋找沿着線的東西:

http://domain.com/?m=_!ajax_html_snippet 
01:

<QueryString ~ "m=_!"> 
    Header set X-Robots-Tag "noindex, nofollow" 
</QueryString> 

這樣下面的網址不會得到被搜索引擎索引

任何提示/技巧/線索將不勝感激。謝謝。

回答

5

您可以嘗試在你的.htaccess文件

#modify query string condition here to suit your needs 
RewriteCond %{QUERY_STRING} (^|&)m=_\! [NC] 
#set env var MY_SET-HEADER to 1 
RewriteRule .* - [E=MY_SET_HEADER:1] 

#if MY_SET_HEADER is present then set header 
Header set X-Robots-Tag "noindex, nofollow" env=MY_SET_HEADER 
+0

創造性的方法如下。謝謝。 – 2012-01-11 00:14:04

相關問題