I've researched and tried to come to some conclusions for how file references work in htaccess directives, that are processed for subdomain requests. I'm seeking confirmation or additional insight ...
This is motivated by:
- wanting a static configuration specified in domain's root htaccess, that will also apply to subdomains (whose root directory are in subdirectories below domain root)
- not wanting to have any specific configuration required within subdomain file hierarchy (either htaccess or symlinks)
- not wanting external redirects for certain cases (such as an error document or a site-wide maintenance page--that are used both for domain and subdomains)
All mentioned below is in the context of:
- Apache 2.2 (interested in knowing about any differences in later versions--as it relates to this discussion)
- Subdomain requests
- Subdomains are hosted on the same server as the domain and exist in subdirectories below the domain root
- In my particular configuration, htaccess files in ancestor directories--above the subdomain root--ARE being read and processed for subdomain requests
- htaccess being only option available for altering server configuration, and thus only referring to htaccess-allowed directives
- There are no mod_rewrite rules for redirecting subdomain requests (automatically handled by hosting configuration)
My conclusions are:
All absolute file/url references (in directives) are relative to subdomain root -- even for directives applied from htaccess files in ancestor dirs (ancestor to subdomain root)
File/url references in htaccess files have no way of referencing files outside of subdomain file hierarchy (without using fully qualified reference with domain host name) -- even for directives applied from htaccess files in ancestor dirs
Meaning, there are no means within Apache to have a directive reference a file outside of the subdomain file hierarchy (without an external redirect) -- even for directives applied from htaccess files in ancestor dirs
So the only ways for directives to actually/effectively reference files outside of subdomain file hierarchy are:
-- using symlinks within subdomain file hierarchy
-- using php/other scripts/programs (within subdomain) to access files outside subdomain hierarchy
And if that's to be avoided (part of original motivation), either:
-- Subdomains need to reflect/mirror same files/file structure as domain (in terms of directive file references in domain htaccess files, for working the same for both domain and subdomain requests)
-- Or htaccess files in ancestor dirs need to have different sets of directives for subdomains (and since neither Directory or Alias is allowed in htaccess, must use mod_rewrite, and even so file/url references are still relative to and constrained by the subdomain file hierarchy)