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

We've got multiple sites that are pointing to the same directory. This is because they are basically the same site, the only differce is, the language. Now we've got a plan to change the design for only one of these sites. We want to keep the complete structure of the site, so moving is no option. But we want only a couple of files different from the other sites. I want to create the following situation in apache:

Two directories:

  • /website/dir_A
  • /website/dir_B

When let's say an image is called: http://website/img/logo.png It has to give logo.png back that is part of dir_A. If dir_A doesn't contain logo.png, it has to give logo.png back that is part of dir_B.

I had hoped "Alias" could do this, but couldn't.

share|improve this question
up vote 3 down vote accepted

You can do this with mod_rewrite. I think doing something like this should work:

DocumentRoot /website/dir_A
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /website/dir_B/$1 [L]
share|improve this answer
You might consider putting all of the rewrite-related directives in a <Location> block so as to specify that the rewrites would only apply to the directory that could contain files he wants to serve. – Clint Miller Jul 8 '10 at 14:40
how do you mean with location? And the rule should point to the directory within the documentRoot set within Virtualhost? <VirtualHost :80> ServerName DocumentRoot /home/abc/ <location /img> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.)$ /site/bbb/img/$1 [L] </location> </VirtualHost> – Ronald Oldenburger Jul 8 '10 at 15:06

I don't know of a way to do this via Apache directly, but if you are running on a dedicated server of VPS (rather than shared hosting) running Linux you could use a union filesystem to achieve this.

share|improve this answer

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.