Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of clients that have different site designs but all run on the same backend CMS. They all share a common admin theme which is located in /home/public/skins/admin - which each client has an alias to.

It works fine but now there could two ore more clients which will share the same design. So it would make sense to move the design to /home/public/skins/design.

I could use a simple Alias of /skins/ /home/public/skins/ but for some older clients, the /skins/ folder will still need to be accessible as it currently is - as each site that uses the same CMS includes the same Alias config file it would be messy to keep some clients using one setting and others a different set.

So, my question is: Can I set an alias to look to the /home/public/skins folder only if the actual folder doesn't exist. Like cascading directory structures I guess.

/skins/design - if exists, do nothing and let the standard directory do the work. otherwise look to /home/public/skins

I'm open to using symbolic links but I like to have alias's for ease of use.


share|improve this question
up vote 1 down vote accepted

Update: i just noticed this section in the manual for mod_rewrite which describes pretty much a scenario which fits your use-case

I can think of 2 options in apache, and then a 3rd is to fall back to a bash script to generate the correct aliases conditionally.

1) The obviously best way is to use mod_rewrite to conditionally re-write the request.

My first idea would be a fairly brutal catch-all, to catch any file missing requests, and redirect them to the default file-path location like so;

RewriteEngine On
RewriteCond  %{DOCUMENT_ROOT}/%{REQUEST_URI}  !-f
RewriteCond  %{DOCUMENT_ROOT}/%{REQUEST_URI}  !-d
RewriteRule  ^/skins/(.*)$               /home/public/skins/admin/$1

2) use mod_perl to conditionally select the aliases with an inline-perl stanzas

3) use bash

 for foo in user1 user2 user3; do
 [ ! -d /home/someuser/skins -a ! -L /home/someuser/skins ] && ln -s /home/public/skins /home/someuser/skins

(there is a note about substitution flags, if you want to mix mod_alias and mod_rewrite flags in to docs...

share|improve this answer
Don't use the Alias. The rewrite will always prefer the file path. – adaptr Apr 23 '12 at 10:25
@adaptr right, ive updated the answer to reflect that. CHeers – Tom H Apr 23 '12 at 10:42
I think the rewrite is along the right track but any rules I add are currently being ignored. Trying to play around with Allowoverride by nothing is working yet. Anything else that might cause it to be ignored? – Ashley Apr 23 '12 at 21:06
i think RerwriteLog directive should get some information back - and probably increment RewriteLogLevel as well – Tom H Apr 24 '12 at 5:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.