Cascading resource selection using mod_rewrite
I'm looking into setting up an application where there is a core and a project namespace, where core is the default fallback to the project customisation. to this end id like to be able to cascade various resources like css, javascript etc. for the purposes of the excersize, ive simplified this as

    ./.htaccess
    ./first/firstonly.txt
    ./first/both.txt
    ./second/secondonly.txt
    ./second/both.txt

expected behaviour would be a request would check for existence in first before looking in second, and finally throwing 404.

for baseurl/firstonly.txt would hit ./first/firstonly.txt (200),   
whereas baseurl/secondonly.txt would try ./first/secondonly.txt (404) then ./second/secondonly.txt (200).   
baseurl/both.txt would hit ./first/both.txt (200) and go no further.  
baseurl/nonexistant.txt (404) would run through the cascades and return 404.

I'm fairly competant with mod_rewrite, so dont feel the need to talk basics here. What would be the most efficient (sane) way of implementing this? Speed concerns aside, as most of the time things will be found on the first hit.
Cascading resource selection using mod_rewrite
===

I'm looking into setting up an application where there is a core and a project namespace, where core is the default fallback to the project customisation. to this end id like to be able to cascade various resources like css, javascript etc. for the purposes of the excersize, ive simplified this as

    ./.htaccess
    ./first/firstonly.txt
    ./first/both.txt
    ./second/secondonly.txt
    ./second/both.txt

expected behaviour would be a request would check for existence in first before looking in second, and finally throwing 404.

for baseurl/firstonly.txt would hit ./first/firstonly.txt (200),   
whereas baseurl/secondonly.txt would try ./first/secondonly.txt (404) then ./second/secondonly.txt (200).   
baseurl/both.txt would hit ./first/both.txt (200) and go no further.  
baseurl/nonexistant.txt (404) would run through the cascades and return 404.

I'm fairly competant with mod_rewrite, so dont feel the need to talk basics here. What would be the most efficient (sane) way of implementing this? Speed concerns aside, as most of the time things will be found on the first hit.