如何在apache中禁止以下url;如何根据查询字符串在apache mod_rewrite中禁止url?
main/index.php?site=ing
我曾尝试以下;
RewriteRule ^main/index.php?site=ing - [F]
,但没有运气...
如何在apache中禁止以下url;如何根据查询字符串在apache mod_rewrite中禁止url?
main/index.php?site=ing
我曾尝试以下;
RewriteRule ^main/index.php?site=ing - [F]
,但没有运气...
你cannot match a query string in the RewriteRule,你所要做的
RewriteCond %{QUERY_STRING} site=ing #Adjust the regexps with anchors
RewriteRule ^main/index.php - [F]
另一个非Apache的解决方案,将是这样做的index.php文件。
将这样的东西添加到页面顶部。
if(isset($_GET['site']) && $_GET['site'] == 'ing'){
header('HTTP/1.1 403 Forbidden');
exit();
}
这应做到:
RewriteCond %{QUERY_STRING} (^|&)site=ing(&|$)
RewriteRule ^main/index\.php$ - [F]
我加入标题和标签“查询字符串”,让人们搜索与查询字符串和mod_rewrite的问题,就会发现这一点。 – 2009-07-06 17:19:29