Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

Currently i'm getting a DDoS attack directly to this URL: myserver.com/?task=randompost, the "?task=randompost" doesnt exist anymore so they get redirected to the home webpage. Considering that they are attacking directly to that url path, its there any way to block all users that tries to enter that path??

Thanks!

share|improve this question

marked as duplicate by Tom O'Connor Aug 25 '13 at 21:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

This can be done with mod_rewrite:

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} =task=randompost
RewriteRule ^$ - [F,L]

This will ONLY work for example.com/?task=randompost request (will not work for example.com/index.php?task=randompost) and it needs to be placed in .htaccess somewhere at the top (before any other rewrite rules). If placed in virtual host context, the ^$ needs to be replaced by ^/$.

The [F] flag will instruct Apache to return 403 error immediately.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.