0

I have a directory structure with files under directory 'web', which represents a white-label web site (html files, images, js etc.). I also have some twenty different 'brands' let's call them 'web-1', 'web-2' etc. each containing specific files that should override the files in 'web' for a specific brand.

Apache is configured to find the files for each virtual site i in document root 'website-i'. In order for each 'website-i' to contain content like 'web' with the overrides for brand 'web-i', my build script first copies all of 'web' to 'website-i' and then overrides it with the source files from 'web-i'.

There several problems with this approach:

  1. It takes time to copy the files.
  2. It takes a lot of disk space
  3. Adding a new brand requires adding to the script.

Is there a best practice for doing this in a way that does not require duplicating files? (with Apache and Linux)

Hagai Cibulski
  • 4,421
  • 3
  • 20
  • 23
  • Two solution I thought about and I don't like: 1. Using redirects. 2. Creating links for all the files, instead of copying them. – Hagai Cibulski Feb 22 '12 at 13:13

1 Answers1

0

Well, the best solution is with pretty simple server-side code but I'm going to assume you've already rejected that, maybe because you haven't permission to run code on the server (although if your hacking the config then you probably do).

A solution just in config could be to make it serve from the default root but rewrite the url if the file exists in the proper dir ...

RewriteCond  /web-1/a_file  -f
RewriteRule  ^(.*)$  /web/$1  

But you'd have to do this for every file in every brand. You might be able to be more clever about it if the files are stored in a dir that's the same as the hostname but that's getting too complex for me.

Seriously, server-side code is the way to go on this...

Strangely enough, a work colleague was in pretty much exactly the same situation a couple of weeks ago and he eventually rewrote it as PHP. Each site is a row in a database, one page which pulls out the changed text and urls for images, etc. and falls back to a default if there's nothing there.

Having said all that. Using links, as you say above, solves problem 2, probably much of 1 and I don't think there's a way around 3 any way.

Kevin Hughes
  • 600
  • 7
  • 18