Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following VirtualHost section:

UseCanonicalName Off
NameVirtualHost *:80
<VirtualHost *:80>
    VirtualDocumentRoot /sites/%0/httpdocs/
    ##VirtualDocumentRoot /sites/%-2/httpdocs/
    #VirtualDocumentRoot /sites/%-2.0.%-1/httpdocs/
    ##VirtualDocumentRoot /sites/%3+/httpdocs/
    <Directory />
        Order Allow,Deny
        Allow from all
    RewriteLog "/etc/httpd/logs/rewrite_log"
    RewriteLogLevel 0

And my directory structure as

  • /sites/blog.domain.com/httpdocs/
  • /sites/shop.domain.com/httpdocs/
  • /sites/www.example.com/httpdocs/

What I want to do is have the example.com work with and without www.

You can see the VirtualDocumentRoot settings I have tried with interpolation. The ## means I had zero success. The # I had minor success with but then none of my other sites will come up. I get

Not Found

The requested URL / was not found on this server.

I feel I am doing something wrong. But I cannot see it. The first question is, how do I make this work? Next, is it possible to see which folder exactly the VirtualDocumentRoot is trying to open?

share|improve this question
Does this answer cover what you're looking for, or does the handling need to be more specific than that? –  Shane Madden May 2 '13 at 17:42
@ShaneMadden Technically, yes. I was hoping to be able to avoid a bunch of empty folders that do nothing but redirect. Is this just a limitation of Apache and I am hosed? –  t3h-chipmunk May 2 '13 at 18:01
Well a symlink isn't really an empty folder, but the second half of that answer, the mod_rewrite solution, might be want you want if you don't want symlinks? –  Shane Madden May 2 '13 at 19:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.