I have a list of over 400,000 IP addresses I would like to detect when they try to access my site, and silently reroute them to another web page. Don't ask why. Would it be faster (and with less strain on my server) to do it in 1) php with something like this <?php $deny = array("111.111.111", "222.222.222", "333.333.333"); if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) { header("location: http://www.google.com/"); exit(); } ?> Code (markup): 2) or in .htaccess with mod_rewrite 3) or maybe in my httpd.conf file?
.htaccess is obviously faster; but large .htaccess files can hang up the server. If this is for blocking specific countries, try the apache mod_geoip
would be fast if you put it in httpd.conf, and would be a bit more fast if you put in .htaccess and less fast if you put in the php file. because thats the way the flow of control happens.
If it's "your server" and it's Linux write a script with ipchains/iptables. keep the IPs in a DB. That would be the most effective.