如何在apache中禁止以下网址;
main/index.php?site=ing
我尝试了以下内容;
RewriteRule ^main/index.php?site=ing - [F]
但没有运气......
答案 0 :(得分:16)
你cannot match a query string in the RewriteRule,你必须做
RewriteCond %{QUERY_STRING} site=ing #Adjust the regexps with anchors
RewriteRule ^main/index.php - [F]
答案 1 :(得分:3)
这应该这样做:
RewriteCond %{QUERY_STRING} (^|&)site=ing(&|$)
RewriteRule ^main/index\.php$ - [F]
答案 2 :(得分:1)
另一个非apache解决方案是在index.php文件中执行此操作。
在页面顶部添加这样的内容。
if(isset($_GET['site']) && $_GET['site'] == 'ing'){
header('HTTP/1.1 403 Forbidden');
exit();
}