views:

263

answers:

3

How do I make the following url forbidden in apache;

main/index.php?site=ing

I have tried the following;

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

but with no luck...

+6  A: 

You cannot match a query string in the RewriteRule, you have to do

RewriteCond %{QUERY_STRING} site=ing     #Adjust the regexps with anchors
RewriteRule ^main/index.php - [F]
Vinko Vrsalovic
+1  A: 

Another non apache solution, would be to do this in the index.php file.

Add something like this to the top of the page.

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

This should do it:

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