I\'m hoping there is a way to do this with mod_rewrite and Apache, but maybe there is another way to consider too.
On my site, I have directories set up for re-skinn
I seemed to have at least one problem with each of the examples above. %{DOCUMENT_ROOT}
seemed to do the wrong thing in certain places, and some /
characters seem to be missing. Here is my solution, which goes in the .htaccess
in the web root.
Instead of using two rules (one for the case where the file under clients/ is found, and one for not found), all I need to check is if the requested file (or directory) does NOT exist. Because if it exists, no change is needed, it can just use the file provided in the client dir. Here's the code I settled on:
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/clients/$1/$2 !-f
RewriteCond %{DOCUMENT_ROOT}/clients/$1/$2 !-d
RewriteRule ^clients/([^/]+)/(.*)$ $2 [L]
Thanks for your help!