2009-07-06 77 views
12

如何在apache中禁止以下url;如何根据查询字符串在apache mod_rewrite中禁止url?

main/index.php?site=ing

我曾尝试以下;

RewriteRule ^main/index.php?site=ing - [F]

,但没有运气...

+0

我加入标题和标签“查询字符串”,让人们搜索与查询字符串和mod_rewrite的问题,就会发现这一点。 – 2009-07-06 17:19:29

回答

1

另一个非Apache的解决方案,将是这样做的index.php文件。

将这样的东西添加到页面顶部。

if(isset($_GET['site']) && $_GET['site'] == 'ing'){ 
    header('HTTP/1.1 403 Forbidden'); 
    exit(); 
} 
3

这应做到:

RewriteCond %{QUERY_STRING} (^|&)site=ing(&|$) 
RewriteRule ^main/index\.php$ - [F]