Welcome to WebmasterWorld Guest from 126.96.36.199
I have a website where I am doing a lot of mod_rewriting. As such it works fine (just about every single page request is a .html url being rewritten to a php script that draws from mysql). The server is an almost dedicated box (I have a few low traffic sites there as well), Pentium III 733 and it has atleast 30,000 daily pageviews (probably 50,000). Everything runs well, very quick response times.
Now my question is, where I should do my mod_rewriting for best performance. At this time I have 8+ directories that contain a .htaccess that does the mod_rewrites for the directory; ie. in directory x: I might redirect ^[a-z]+.html$ to /scripts/page.php?section=x&p=$1. I am wondering though.. Should I instead delete all those directories and do it all via a number of rewrite rules in a single .htaccess at public_html/? ie. for directory x ^x/[a-z]+.html$ to /scripts/page.php?section=x&p=$1 etc. In short it is: ONE big .htaccess (more rules to check with each hit) for all rewrites/error page definitions etc. rather than one in each directory(less rules to check)?
Welcome to WebmasterWorld [webmasterworld.com]!
The most efficient approach will be to try to achieve the following:
Of course, this is much easier to do with a new site design, when you can plan ahead.
Additionally, those RewriteRules which apply to most files and which are not likely to change can be placed in httpd.conf if you have access to the server configuration. Directives placed in httpd.conf are compiled on server restart, rather than being interpreted on a per-request basis. Therefore, they are processed much more efficiently.
Good to hear that :) Based on what you are saying I believe I have a fairly optimized design already, except files are not ordered by file types but by which sections they belong in- it is important for me to have a site directory structure that is fairly human-readable :)
Yes, you can, IF you have access (priveleges) to modify httpd.conf, and IF the "design" of your code is stable and not likely to change. However, the great majority of Webmasters do not have access to httpd.conf, thus leading to the popularity of .htaccess.
The original post mentioned only .htaccess, so the thrust of my reply was to .htaccess, but I did mention httpd.conf as a final note in my first reply.
Do you have a question about what is posted here, or are you just commenting on the use of httpd.conf?