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'm working on ubuntu with apache2.


  1. The root directory should be served from a specific folder. When someone accesses he should reach /var/www/tld/foo1
  2. Other directories as sub-sites: When someone accesses he should reach /var/www/subsite/foo2
  3. I would like to be able to configure specific shortcuts for some actions. E.g. by adding a custom rule, I would like to reach (unlike #1, this is not global, but just by adding specific routes).

What's the best way to achieve this? Should I have a different file under apache/site-enabled per "subsite"? Or should I use <Directory>? How do I configure mod_rewrite to achieve this?

share|improve this question
up vote 2 down vote accepted

A virtualhost has only one documentroot; apache has no concept of "subsites".

Vhosting documentation

You can make exceptions to this by adding an Alias that points to a filesystem location outside the documentroot, but take care in what order you define these: the first match wins, so you should order them from most specific to least specific.

Alias documentation

The last question is more a case of bad site layout, but you could issue a Redirect for it:

Redirect /foo3/ /subsite/foo3/

There is no module named mod_routing in apache.

share|improve this answer
Removed mod_routing, evaluating the rest of you answer. I'll try out Aliases. – ripper234 Jan 2 '12 at 12:02
On ubuntu, the solution was editing mods-enabled/alias.conf and adding Alias /foo2 "/var/www/foo2". Thanks! – ripper234 Jan 2 '12 at 12:15

If all URLs are hosted under the same domain/IP address, you can use mod_rewrite to rewrite the URLs according to the rules you specify.

share|improve this answer
See above (Replaced mod_routing with mod_routing/mod_rewrite): How do I configure mod_routing/mod_rewrite to achieve this? You can tell me to RTFM if you want. – ripper234 Jan 2 '12 at 10:40
There are many documentation on using mod_rewrite. You can start using it and if you need help you can ask another question. – Khaled Jan 2 '12 at 10:45

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.