Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have an Apache server that I am running on localhost. The root http://localhost should go to a VirtualHost application (Joomla!), while I want http://localhost/test to go to a second VirtualHost - a simple index.html test file. I believe I want to user mod_rewrite for this, so I have that installed.

I have the following two VirtualHosts defined (I am using Ubuntu 11.04):


<VirtualHost localhost>
    ServerAdmin webmaster@localhost
    ServerName localhost
    DocumentRoot /srv/joomla


<VirtualHost localhost>
        ServerName localhost
        DocumentRoot /srv/test
    ServerPath /test/
    RewriteEngine On
    RewriteRule ^(/test/.*) /srv$1

However, when I go to http://localhost/test/index.html or even http://localhost/test I get a 404. What am I doing wrong? Thanks!

share|improve this question
ServerPath is for legacy support of clients that don't send Host headers correctly. Ignoring the technology, what are you trying to achieve ? – Iain Aug 30 '11 at 18:52
@Iain - I am trying to have one process handle all requests to localhost and then have a totally separate process running Mono to handle localhost/myapp. It looks like I can probably do this with Alias. Is this the intended way? Is there any way I can do it finer grained, like in a separate VirtualHost? – skaz Aug 30 '11 at 19:32
You are using mod_mono ? – Iain Aug 30 '11 at 20:08
@Iain Yes, I am. It looks like it is working with Alias but I still figured there would be a better way... – skaz Aug 30 '11 at 20:29
up vote 1 down vote accepted

The mono project has extensive documentation on setting this up. In particular they suggest using an Alias directive and a Location block

Alias /test "/usr/share/doc/xsp/test"
MonoApplications "/test:/usr/share/doc/xsp/test"
<Location /test>
    SetHandler mono
share|improve this answer
Thanks for your help! – skaz Aug 31 '11 at 3:02

You can't have 2 identical virtualhosts defined, they need distinct servernames

Combine your confs into one file (what you probably want) or run them on different ports or give them different names

share|improve this answer
I was attempting to do what was described in this post:… Do you know anything about that? How would I get that to work? Here is the Apache documentation: – skaz Aug 30 '11 at 16:33
Note they have the same VirtualPath in that documentation. – skaz Aug 30 '11 at 16:34
The apache documentation has different ServerNames for each Virtual Host directive, which is how Apache figures out where the request should go (by the Host Header that matches the ServerName). The old ServerPath setting is for when Apache gets an ancient HTTP 1.0 request, no Host Header, so all Virtual Hosts fall in the same domain and a prefix is added to requests to indicate which server the request is supposed to be addressing (this is messy, ancient, and unsupported by almost everything these days). – Chris S Aug 30 '11 at 20:13

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.