Forum Moderators: phranque
There is no easy way with .htaccess. You have to store dynamic counters for every IP address somewhere and compare them with X.
If you want a complex logic, you would have to implement it.
In this case you would need something like this:
After creating a database table holding an indexed row for IP-addresses and one for a counter,
just put the following small logic at the top of your file.php:
Look for the counter of a certain IP-address in the database.
If it is there and < X, then update that record and write back an X+1.
If it is not there, then insert a new record for that IP address with X=1.
If the counter is <= X then proceed with giving out the page, else just say 'no' and exit.
Perhaps you may wish to add a 3rd row holding an updated datetime stamp, too, so that you could delete old records after a while, which would require some additional logic then.
Kind regards,
R.
You should be able to make adjustments to this script, Updated PHP Bad Bot Script [webmasterworld.com], to do what you want.
Andrew