2

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.

Thanks

1 Answer 1

1

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
 done

(there is a note about substitution flags, if you want to mix mod_alias and mod_rewrite flags in to docs...http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule)

4
  • Don't use the Alias. The rewrite will always prefer the file path.
    – adaptr
    Apr 23, 2012 at 10:25
  • @adaptr right, ive updated the answer to reflect that. CHeers
    – Tom
    Apr 23, 2012 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, 2012 at 21:06
  • i think RerwriteLog directive should get some information back - httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog and probably increment RewriteLogLevel as well
    – Tom
    Apr 24, 2012 at 5:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .