Preventing DDOS attacks on your website

This line of code below disallows blank useragents to your website. This normally prevents bots and auto-generated spambots from hitting the site causing the server to slow down tremendously. Simply add the line of code in your script just before it loads the layout.


if(($_SERVER['HTTP_USER_AGENT'] == "") || ($_SERVER['HTTP_USER_AGENT'] == "-")){
die();
}

This will disallow all user agents with no name or with a – in the name.

thats it, quite simple..

credits: Kenetix

Advertisements

About this entry