I want to host two different websites on the same domain, example:

<VirtualHost *:80>
    DocumentRoot /var/www/www1/
    ServerName my.domain.com

<VirtualHost *:80>
    DocumentRoot /var/www/www2/
    ServerName my.domain.com/www2

This config is ofcourse wrong, but it depicts what I want to do. When someone go to my.domain.com he will be served by web application from /var/www/www1. When someone go to my.domain.com/www2 he will be served by web application from /var/www/www2. Is this possible in Apache?

  • -1, vote to close - question makes no logical sense and is contradicting itself. – TomTom Dec 3 '10 at 11:45
  • It makes sense to me and my use case, since those webapps are closely related to each other but they need to have standalone codebase. – yojimbo87 Dec 3 '10 at 11:53
  • your question doesn't make sense because you've got the terminology and functionality of Apache confused. Looks like Casual figured out what you meant, even if others couldn't. In the future you might want to simply explain your requirements instead. In this case, you might have simply said that you have two web apps that need to be in different directories on the server, and need to be presented as domain.com and domain.com/www2. – Chris S Dec 3 '10 at 14:09
  • @Chris S: Serverfault is Q&A site and asking questions when I am confused about something should be normal. My requirements were explained in the question or comments and the example configuration was meant only to show how I wanted to do it. Polite person who is willing to help asks for further clarification if he doesn't understand the question. It's interesting that two people here were perfectly able to answer my "senseless question" (thank you Casual Coder and Denis) while other person went berserk with down voting even the person who actually solved the problem. – yojimbo87 Dec 3 '10 at 16:12
  • don't be too offended by that particular person; he's got a long history of comments and answer like that. Many SysAdmins have a well deserved reputations for being terse. Server Fault is also a public website, like any other, you get the good with the !good. – Chris S Dec 3 '10 at 16:27

You are not really configuring named virtual hosts or ip based virtual hosts, so forget about second VirtualHost entry and set an alias in first:

Alias /www2 /var/www/www2
| improve this answer | |
  • Not answering the question as asked, sorry. Mostly because teh question makes no sense. – TomTom Dec 3 '10 at 11:45
  • 1
    His answer was the solution... And the question wasn't clean, but answerable. – zaub3r3r Dec 3 '10 at 11:58


This isn't true FQDN, but FQDN with path. You cannot point this as domain. Use aliases.

| improve this answer | |

I want to host two different websites on the same domain, example:

DocumentRoot /var/www/www1/ ServerName my.domain.com ... DocumentRoot /var/www/www2/ ServerName my.domain.com/www2

Senseless question on the level of "I want to eat a vegetarian cw steak".

Basically, if you want to use two domains, then USE TWO DOMAINS. Your example uses the same domain, so it does not match the titel and text.

Showing two different contents under the same domain DOESN OT WORK. Shwoing different contexts in different folders under a domain works, but iti s not the same as hosting the same website under two domains.

| improve this answer | |
  • Webapps codebase is different and it needs to be served standalone, context of those applications remains the same within the domain. – yojimbo87 Dec 3 '10 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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