Forum Moderators: phranque
On most of my sites, I originally started with all .htm files, but over time I added php code into many pages. I wanted to leave the extensions the same, just so I would not have to worry about broken links, etc..
So I started using AddHandler to set the server to process .htm files as php files.
I remember reading once somewhere that this can cause speed issues, since the server looks for php code in every page. I imagine this cannot be worse than having all your pages .php anyway.
Has anyone here ever experimented with .htaccess code, to see if it can really cause that much extra work for the server? I know it loads .htaccess anytime anyfile is downloaded, but is it really that significant of a difference in general?
Link to thread, msg #75 [webmasterworld.com]
This should relate to what you are doing.
Without this Apache still has to search every directory from the document root down to the target file's directory for a .htaccess file. The directory traversal and stat'ing is relatively expensive.
I didn't see in either of those threads if that had been done for the benchmarks. I haven't benchmarked it myself, but the Apache foundation folks put this tip pretty much at slide #1 in both Apache performance presentations I've attended.
I do not know if I am ready right now to totally ditch the .htaccess, but I will keep that idea in mind. I of course have access to the httpd.conf, but I have little experience with putting the rules in there.
A lot of the code has to be changed right? I mean, I cannot simply copy and paste from the .htaccess to the section in the conf?
Basically Apache does this for you when it loads an .htaccess file; if you have /web/htdocs/.htaccess it internally thinks to surround the file's config rules with <Directory /web/htdocs></Directory>. You need to make this mapping between directories and rules explicit when you use the httpd.conf only.
I spent a couple hours going through all my sites, removing every single .htaccess file and sticking the contents into httpd.conf.
I had to keep looking up a lot of info, but I finally got it! Everything is working great. I just set all of my AllowOverrides to none after all of it with my fingers crossed, and no problems at all.
I had to modify all my rewrite rules a bit for a few different sites, and I learned some interesting new ways to do what I had been doing.
Thanks for the info once again! :) It may be my imagination, but everything seems so much quicker!