Order Deny,Allow
allow from 123.123.123.123
allow from 124.125.126.127
Deny from all
Is there a way I could avoid repeating the "allow from" (or "deny from") part for each of the IPs? Or is there a way I could supply the IPs from an external file?
Of course, I can write a PHP script that will create the .htaccess file in the right format but there can be many IPs and if the "allow from" does not have to be repeated on each line, I could save some bytes. It may be totally unimportant but...
Ok folks, still looking for a solution to this problem... I am sure there is one, right?
I wrote a php script that does the proper formatting but if there are many IPs and you need to repeat the "allow from" part for each of them, it does add a lot of kilobytes to the .htaccess file which I want to avoid if possible.
So the question once again is: Is it possible to include an external file with IPs (one IP per line) from within .htaccess and tell Apache to share the same (allow or deny) directive for all of them?
i see that you can buy a hd with 40Gb for 40€ => 1€/1Gb.
don't see how those few bytes can be worth the effort.... (and that is also a reason why configuration files are plaintext and not tarred/zipped.)
I am not worried about the space it takes at all. I am worried about the performance issue. In my opinion, it is more work for Apache to load a 60KB file than a 25KB file - and yes, the few characters on each line can make such a big difference.
- How many times do you plan to (re)load the configuration then?
- Have you already measured the difference in loading time between a 60kb file and a 25kb file?
- Presume apache would allow you to pass multiple hosts separated by a comma. In that case apache would have to loop through a _big_ string and find every , that separates the hosts. I don't think performance will be very different.
Btw, i believe you have to separate them with a space " ".
From the manual:
Allow directive
Syntax: Allow from all|host|env=env-variable [host|env=env-variable] ...