I approached the development team requesting permission to turn the option off, in order to squeeze some extra performance out of each server. Rather than the happy smiles and agreement I expected, I was instead met with nervousness and uncertainty. Since the front end team uses them constantly, there was concerns that the change over from .htaccess to httpd.conf would consume a lot of time, and would be very difficult to maintain moving forward.
In order to allay their fears I created a .htaccess to httpd.conf script with the help of my friend Rich Bowen. It's designed to be executed from the command line from a sufficiently permissioned user from within the document root. It recursively scans all sub directories looking for .htaccess files, reads them in, and spits it all back out. There's a bit of intelligence involved in order to present the contents of .htaccess files with the least depth first (this way overriding works correctly), and warnings are generated if the RewiteBase instruction is encountered as it may require extra tweaking. Other than that I generally just pipe the output to htaccess.conf, then include that file from my basic configuration file. By re-running this script (and, of course, gracefully restating the server after checking to make sure all the conf files parse) as part of my normal sync process I get all the flexibility of .htaccess files, without the performance hit.
The script requires PHP 5, probably 5.1+ would be safest.
No warranties, test extensively. In terms of field testing (against my rather limited set of .htaccess files) it's been running on a site +10M uniques/day, using roughly 40 .htaccess files. I'd love to hear from you if you end up using it.
Source:.htaccess to httpd.conf converter, and again with thanks to Rich Bowen.
Comments »
- The more heavily loaded your server is, the more this will help.
- IO bound systems will see more than others
- The more nested your directory structure for file and URLs, the more .htaccess files apache will look for, so the more it will help.
So no hard and fast numbers, your mileage will vary.
Do you have any kind of information about what kind of improvement you saw after making this change?
Also some benchmarks would be so interesting
[code]
//Merge base set of filters with any from the command line
if(count($argv) > 0)
{
unset($argv[0]);
$filters = array_merge($filters, $argv);
}
[/code]
It will only kick out a PHP Notice of an undefined variable. Unless this is a part of PHP I am not familiar with I am assuming the code above is useless.
Thanks for the script! Very useful.
I am a newbie in php
I want to know how to change the url address for remote access.
I don't know how to use .htaccess and httpd.conf
I found many topics related these but still can't.
e.g http://192.100.0.23/myfolder/login.php
to
http://192.100.0.23/newname
waiting for reply.....

Can't wait to try this script out.