Welcome to WebmasterWorld Guest from 188.8.131.52
Is there a way to avoid multiple htaccess files and to use a common httpd.conf with subdirs?
that last one being the biggest reason for me to move them from httpd.conf to .htaccess...
currently, i have one .htaccess file in the root of each of my domains and that file covers the rewrite rules for all the directories...
note, however, that this is also pertenient to how you have defined your directories in the httpd.conf file... on my system, i have "virtual" directories defined in the httpd.conf file... "virtual" in that you access them by a name different than they carry on the filesystem... in those definitions, i had place restrictions... with those restrictions i had to have seperate .htaccess files for each of them... once i removed those restrictions, i was able to remove the .htaccess files and centralize everything in the main one in the root directory...
another thing to consider for multiple .htaccess files is that the more you have in one, the longer (minute as it may be) it takes top process... also when the system looks in a directory and doesn't find a .htaccess file, the system will back up thru the directory structure looking for one... since the .htaccess file is looked for and processed on each request, it is possible that one could cause a slowdown on their server... how much of a slow down or performance hit is dependant on the size of the .htaccess file and the contents as well as the ordering of the rules...
> Rewrite on
Also, the "escaping" rules for mod_rewrite are a bit different than those for Perl or PHP, so you can leave out the escapes for "/". Parentheses are only required to create back-references, to group characters for quantifiers, e.g. "([0-9]A)+", or to mark the borders of alternatives, e.g. "(A¦B¦C)". Quotes are not needed around the URI substitution string:
RewriteRule /img/.*\.png$ /cgi-bin/b-tested.cgi [L]
The server will traverse the web site's entire directory structure, executing each .htaccess file it encounters as it works its way down to the requested resource. Lower-level .htaccess files (executed later) can therefore override (replace) options set by higher-level .htaccess files. But if a higher-level .htaccess file redirects a request before it gets to a given lower-level .htaccess file, then that lower-level .htaccess file will not be processed.
As wkitty42 says, you may want to develop and test your rewrite rules in .htaccess, and then move them up to httpd.conf once they are working. This saves on server restarts, but does require you to modify your rules to account for the differences between the .htaccess and httpd.conf contexts.