Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Block user IP's with .htaccess or PHP?

Tags:

php

.htaccess

From a performance only view, which would be the best way to block 30 IP addresses?

A) .htaccess file

or

B) PHP code in the file

like image 454
JasonDavis Avatar asked Jan 19 '10 00:01

JasonDavis


1 Answers

If you are administrator of your server, I would use none of those, and would ban the IPs at the firewall level -- this way, nor Apache nor Apache+PHP will have to work.

If you're not admin ; well, .htaccess means only Apache, and no PHP to load/compile/execute ; I'm guessing Apache alone (i.e. .htaccess) should require less resources than Apache+PHP.


Another way of seing things is maintenance : if you need to add/delete IPs addresses from that list, what would the easiest way be ?
(In that case, I would generally bet for some PHP code...)

like image 86
Pascal MARTIN Avatar answered Sep 28 '22 22:09

Pascal MARTIN