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 am able to serve and Also works fine too. But not for some reason this doesn't work. I even created a in my sites-availible folder and also enabled it. I reloaded the configuration and yet it still doesn't work.

I have a wildcard certificate so that is NOT the problem.

    <IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName *
        VirtualDocumentRoot /var/www/%0

Thanks for any help.

share|improve this question
If you have a wildcard certificate for *, then calls to should be giving you browser warnings of a certificate mismatch, since * doesn't match – Mike Scott Jan 21 '14 at 21:00

To have the same site listening on both HTTP and HTTPS you will need 2 virtual hosts, one for SSL and one for normal connections.

Remove :443 from your "ServerName" parameter.

I just created a config doing what you request here, in my test environment, and this is what I have in my working configuration file:

<IfModule mod_ssl.c>   
  <VirtualHost _default_:443>
    ServerAdmin www@srv.fbh

    ServerName *.srv.fbh
    VirtualDocumentRoot /www/%0/ 

    SSLEngine on
    SSLCertificateFile    /etc/ssl/test/server.crt
    SSLCertificateKeyFile /etc/ssl/test/server.key   

Also, you have a ServerAlias for - this is not necessary, as the wildcard * will catch this.

share|improve this answer
Hmmm, this didn't seem to fix the problem. – mdgreenwald Feb 13 '11 at 18:51
Part of problem is in the VirtualDocumentRoot line. %0 expands to the incoming domain name, which in your case means Apache would look for the site at /www/, which is not /www/ You could work around this by creating a symlink from one to the other, which is similar to what you did, or a better way would be to modify the VirtualDocumentroot to be VirtualDocumentRoot /www/%-2.0.%-1, which means to take the penultimate and ultimate parts of the incoming domainname, with a dot in between. Both domains would resolve to the path /www/ – Martijn Heemels Jul 28 '12 at 4:03


<IfModule mod_ssl.c>
  <VirtualHost *:443>
    ServerAlias *
    UseCanonicalName Off
    VirtualDocumentRoot /var/www/%0

    SSLEngine on
    SSLCertificateFile      /path-to-keys/ca.crt
    SSLCertificateKeyFile   /path-to-keys/yours.key
    SSLCertificateChainFile /path-to-keys/bundle.crt

    RequestHeader set X_FORWARDED_PROTO 'https'

Of course you need the proper files there, and remember to set yours.key to chmod 400. I did notice you got this part working already, just keeping the answer more complete. ;)

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.