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

I thought I had ssl set up correctly, but I discovered a problem.

This part is OK: ssldomain.com goes to https://ssldomain.com.

But this isn't working: www.ssldomain.com is going to http://anotherdomain.com, which happens to be the first vhost on the machine. In other words, I have a non-SSL vhost running on that server, and www.ssldomain.com is bouncing to that one.

I used this utiltiy and verified that my Commodo "PositiveSSL" certificate covers the domain both with and without the "www".

I'm using Apache 2.2.3-65.

Here's my config in /etc/httpd/conf.d/ssl.conf...

<VirtualHost *:443>
    ServerName www.ssldomain.com
    ServerAlias ssldomain.com
    DocumentRoot "/opt/deployed_rails_apps/ssl_site/current/public"

    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/www.ssldomain.com.crt
    SSLCertificateKeyFile /etc/pki/tls/certs/www.ssldomain.com.pem
    SSLCACertificateFile /etc/pki/tls/certs/www.ssldomain.com.ca-bundle
    SSLHonorCipherOrder On
    SSLCipherSuite ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH
    SSLProtocol all -SSLv2
    Header add Strict-Transport-Security "max-age=15768000"

    ErrorLog "logs/ssldomain.com-ssl-error_log"
    CustomLog "logs/ssldomain.com-ssl-access_log" common
    CustomLog "logs/ssldomain.com-ssl-deflate_log" deflate
    <Directory "/opt/deployed_rails_apps/rock_pebble/current/public">
        Options -MultiViews FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all

# apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443                  ssldomain.com (/etc/httpd/conf.d/ssl.conf:230)
*:80                   is a NameVirtualHost
         default server anotherdomain.com (/etc/httpd/conf/httpd.conf:232)
         port 80 namevhost anotherdomain.com (/etc/httpd/conf/httpd.conf:232)
Syntax OK
share|improve this question
What's the output from apachectl -S? –  Shane Madden Jul 13 '12 at 4:40
See updated question. Thanks. –  Agvorth Jul 13 '12 at 6:30
That config looks good - the ssl.conf vhost will always get every request to port 443, regardless of what host header is on the request. Are you accessing http://www.ssldomain.com, or https://www.ssldomain.com? –  Shane Madden Jul 13 '12 at 22:09
Ah OK, yeah. Entering "ssldomain.com" does what I want -- takes you to "ssldomain.com";. Entering "www.ssldomain.com" serves up the page that's really at "anotherdomain.com", but the browser address bar contains "ssldomain.com";. The status code is 200. –  Agvorth Jul 14 '12 at 18:06
Is there some way I can redirect "www.ssldomain.com" to "ssldomain.com"? Maybe at the DNS level? –  Agvorth Jul 14 '12 at 18:08

2 Answers 2

You can't redirect at the DNS level, but you can easily configure another virtual host on port 80 to handle the redirects.

<VirtualHost *:80>
    ServerName www.ssldomain.com
    ServerAlias ssldomain.com
    # .. logging, anything else you need ..
    Redirect permanent / https://ssldomain.com/
share|improve this answer
up vote 0 down vote accepted

OK, thanks for the help, everyone. I think I have this figured out. I set up both a non-SSL vhost in httpd.conf and the SSL vhost as described in my question in ssl.conf.

The non-SSL vhost has this...

ServerName www.ssldomain.com
ServerAlias ssldomain.com

And the SSL vhost has only this...

ServerName www.ssldomain.com

Within my application code, I'm forcing all traffic to go to the corresponding https URL. Now the URL resolves both with and without the "www" and everything is served over SSL.

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.