I have the following working copy .htaccess file in 4 folders: / (root), /images, /js and /css.
Is there a way that I can make them run from a single .htaccess file from the root of the site?
First, Ralph is correct. .htaccess files are heirarchical so the one in the DocumentRoot is processed first (so that’s where I locate ALL my .htaccess code … unless I have a GOOD reason).
[rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> … </IfModule> wrapper is the same thing in the webmaster world. DON’T BE AN IDIOT! If you don’t know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/indent][/rant 4]
Secondly, DirectoryIndex is supposed to list the default files to be served. If the first does not exist, the next file named (of which there are none) is served. You, on the other hand, seem to be smitten by mssql-version.php. What gives with that? Are you not using Apache (if that’s the case, why are you in the Apache board?). It does not seem to be wrong, just weird.
Lastly, it’s also weird to see checks of the size and link status of the {REQUEST_FILENAME}. What are you trying to accomplish with these?
So much makes no sense that it seemed to beg comment.
I have to drop the same .htaccess into each of the 4 folders.
Rather, I want to use only one .htaccess with definitions for each of the 4 things.
(I don’t care if I have to rename the 4 files differently, if desired).
But my aim is to maintain only one .htaccess file in the parent only.
Can I write multiple rewrite bases in each <ifmodule>? Like:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
...
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /css
...
</IfModule>
Probably not.
DirectoryIndex is not an issue here, but RewriteBase can be.
It is definitely good NOT to check for <ifmodule> in fact, because, until that is available, the system does not work.
You apparently didn’t understand the NEVER USE <IfModule> on a production server. Please think about it: You are making Apache verify the mod_rewrite module for each and every file request (twice now) which is done multiple times for each request anyway (it’s a matter of mod_rewrite processing each request). THAT IS INSANE! Test once, if you must, but NEVER use <IfModule> in an .htaccess file. Note: WordPress includes it to prevent being bombarded by ID-ten-T webmasters who do not have mod_rewrite installed on their servers as unrecognized commands will cause a 500 error for the website. Non-ID-ten-T webmasters will understand that and remove the <IfModule> wrappers after the first test (because a host will not remove a module which is in operation for its clients). In other words, if I were your host, I would not be your host as I’d force you to move to a dedicated server (so you would not slow a shared server) or tell you to find a less intelligent host (who would not know to protect their clients from webmasters who attempt to bring down their server for lack of understanding).
Okay, you didn’t say HOW the files in the directories behave differently but, for your mod_rewrite code, merely add the directory after ^ (in the single .htaccess in the DocumentRoot). Since you’ve not shown any mod_alias Redirects, you do not need any RewriteBase directives so, IMHO, learn what your code is doing before using it (or, in this case, NOT using it)!