Forum Moderators: phranque
Despite various warnings in the apache document I'm trying to learn the intricacies of the mod_rewrite process. A formidable objective considering I'm a webmaster with little to no knowledge of apache.
Can someone explain the difference between a URL manipulation within the per-server context versus the per-directory context?
Thanks,
Chris
It all boils down to permissions and access... If you have access to the top-level Apache server controls, then you can put mod_rewrite code into htppd.conf to control your sites or user accounts from a centralized file.
If you do not have access to that level, then you may be able to install .htaccess files in your directories to accomplish the same thing.
At the server level, you can write mod_rewrite code that applies to all sites or users on that server, or you can write specific code to put in each <directory> container.
Simlarly, at the .htaccess level you can put code in only the top-level Web-accessible directory (where your 'home page' resides, or you can create an .htaccess file for each directory and subdirectory where you need one.
Descriptions 1 and 3 above refer to per-server control, whereas 2 and 4 refer to per-directory configuration. The per-server/per-directory language is a bit loose, so I thought I'd give both perspectives.
Another thing you might want to know is that mod_rewrite code placed into httpd.conf is compiled at server restart, and is executed for each HTTP request. mod_rewrite code placed in a .htaccess file is interpreted for each HTTP request. Therefore, httpd.conf code is processed much faster, but you need aserver restart to change it. One or the other approach may offer you benefits, depending on your site(s).
Ref: Introduction to mod_rewrite [webmasterworld.com]
Jim
So within the Apache API, the URL-to-filename translation hook is what happens immediately upon a http request based upon what's written/compiled in the httpd.conf . This occurs before the per-directory configurations are processed.
After some other steps the Fixup hook will take into account any further configurations by the .htaccess file(s). This is more inefficient because it requires a rewrite of the filename back to its corresponding URL format. I don't really get the distinction on filenames & URL formats but it makes logical sense why it's less efficient. :)
Further "unlimited rulesets" simply means you can use an infinite combination of regular expressions to manipulate the URL to it's final format?
heh, I actually started the day at WebmasterWorld and finished the day as well via a google search which brought up Dave's article. All WM roads lead to WebmasterWorld?