mayur lagad
mayur lagad

Reputation: 75

want to block specific URL pattern in apache using rewrite module

I see some traffic burst on my apache with all invalid URLs but with a specific pattern. Below are the some URLs

www.example.com/?1gx2A1WV=Ji7iMHhDsDOHvesb8

www.example.com/?LTn28PGXpg=VQTNObTmrhyF7Pjs2VoX

So basically I want to block this pattern in apache. anything that has "?" after www.example.com/ should be blocked.

Can someone please help me creating RewriteRule in apache for this. Thanks in advance.

Upvotes: 2

Views: 2793

Answers (2)

Sameer Naik
Sameer Naik

Reputation: 1412

REQUEST_URI does not contain query string. Try matching your rule against QUERY_STRING

Upvotes: 1

nitzien
nitzien

Reputation: 1267

This should help. RewriteCond matches the pattern you have mentioned for request uri. Rewrite Rule sends back 403 as HTTP Response. Your use of Location may vary based on your apache configuration.

<Location />
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/\?.*$ 
RewriteRule ^.*$ - [F,L]
</Location>

Upvotes: 0

Related Questions