1. Trang chủ
  2. Blog
  3. Chia sẻ code
  4. Cách hạn chế tấn công DDOS ?
Chia sẻ code

Cách hạn chế tấn công DDOS ?

Cách hạn chế tấn công DDOS ?

Bước 1: Tạo file .htaccess tại thư mục bị DDoS access/request liên tục (thông thường là các thư mục public_html, forum,…). Nội dung file như sau:


  1. RewriteEngine on  
  2. RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?tendomain.com [NC]  
  3. RewriteRule !antiddos.phtml http://tendomain.com/antiddos.phtml?%{REQUEST_URI} [QSA]  



Bước 2: Tại cùng thư mục file .htaccess , tạo file antiddos.phtml với nội dung:


  1. <?php  
  2.   
  3. $text=$HTTP_SERVER_VARS[‘QUERY_STRING’];  
  4. $text = preg_replace(“#php\&#si”,’php?’,$text);  
  5. echo(‘<div><a href=http://tendomain.com’.$text.’>Welcome</div>’);  

Văn Tình
Văn Tình
Full-Stack Developer

Đam mê code, thích du lịch bụi, lúc rãnh viết blog chia sẽ một vài thứ hay đã từng gặp.