mod_write chống bot và chống flood

File thứ nhất -- .htaccess

  1. // @file <a href="/taxonomy/term/204" title="">.htaccess</a> -- $Id$
  2.  
  3. ErrorDocument 403 /403.php
  4.  
  5. RewriteEngine on
  6.  
  7. # Debug HTTP_COOKIE <a href="/category/ph%C3%A2n-lu%E1%BB%93ng/apache.html" title="">Apache</a> variable
  8. RewriteRule .* - [E=INFO_HTTP_COOKIE:%{HTTP_COOKIE},NE]
  9.  
  10. RewriteCond %{HTTP_COOKIE} !.*IS_NOT_BOT [NC]
  11. RewriteCond %{REQUEST_METHOD} ^GET$
  12. RewriteCond %{REQUEST_URI} !.*403.php
  13. RewriteRule ^(.*)$ 403.php?q=$1 [L,QSA] # I do not know why [L,QSA,R=403] does not work

File thứ hai -- 403.php

<?php
// @file 403.php -- $Id$

if (!empty ($_POST) && isset ($_POST['REQUEST_URI'])) {
  
setcookie('IS_NOT_BOT');
  
header('Location: '$_POST['REQUEST_URI'], TRUE$http_response_code);
  
  
// print_r ($_SERVER['INFO_HTTP_COOKIE']); // print out <a href="/category/ph%C3%A2n-lu%E1%BB%93ng/apache.html" title="">Apache</a> HTTP_COOKIE value
  
  
exit ();
}

?><html>
<head>
</head>
<body>

<form action="<?=$_SERVER['SCRIPT_NAME']?>" method="POST">
  <input type="submit" value="Continue..." />
  <input type="hidden" name="REQUEST_URI" value="<?=$_SERVER['REQUEST_URI']?>"/>
</form>

</body></html>
?>

Tham khảo:
[1] Crazy Advanced mod_rewrite Tutorial

Thế Hồng

Comments

Co' Phai Toila admin MotViSao.com ko ?? ^^!

Vô tình thấy domain này, có phỉa Toila admin MotViSao.com ko ? có phải Toila ko ?? Thái vui ghê zù jì cũng mail thái 1 tiếng nha

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <sup> <br> <p> <h3>
  • Lines and paragraphs break automatically.
  • Link to content with [[some text]], where "some text" is the title of existing content or the title of a new piece of content to create. You can also link text to a different title by using [[link to this title|show this text]]. Link to outside URLs with [[http://www.example.com|some text]], or even [[http://www.example.com]].
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.