Is there a possibility to serve resources hosted with Apache recursively across the directory hierarchy, using mod_rewrite or the like?
Example#1:
A server document css/php/html/...
refers to the resource image.png
at /doc/root/dir1/dir2/dir3/image.png
(requested with http://example.com/dir1/dir2/dir3/image.png
) in the current directory. Apache serves the requested document but looks at dir2/
if it 404s
in dir3/
, then at dir1/
if it 404s
in dir2/
, etc...
I am trying to recreate Zope's ability to serve content that is higher up in the directory tree if it isn't available at the current path.
The idea is to create satellite pages further down the tree that make use of content remaining the same across all pages but that can be overridden if need be.
Example#2:
3 sites under the same domain at http://example.com/sites/site[1..3]/
, all pages refer to header.png
in the current directory. For sites 1 and 2 http://example.com/sites/site[1|2]/header.png
does not exist, but http://example.com/sites/header.png
does - so serve this in place. For site 3 http://example.com/sites/site3/header.png
exists, so Apache serves it as usual, ignoring header.png
further up in the tree.
However, if http://example.com/sites/header.png
does not exist, also check http://example.com/header.png
and serve it in place if it exists. Only return a 404 if this doesn't exist either.
Caveat: header.png
is just an example and it should work for all resources, be they CSS, PHP or other content and as far down the directory tree as DocumentRoot.
Can this be done, and if yes, how?