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 want my website to support both non-SSL and SSL access. What I had to do is copy the non-SSL config and change the port to 443 and add the SSL stuff. Not ideal to administrate!

Is there a way to merge those two configuration?

Here's my current config:

<VirtualHost *:80>
        ServerName www.site.tld
        ServerAlias site.tld

        suPHP_UserGroup site site
        DocumentRoot /path/to/site/www
        <Directory /path/to/site/www>
                AllowOverride All
                Order allow,deny
                allow from all
                Options -MultiViews
        </Directory>

        ExpiresActive On
        ExpiresByType image/gif "access plus 7 days"
        ExpiresByType image/jpeg "access plus 7 days"
        ExpiresByType image/png "access plus 7 days"
        ExpiresByType image/x-icon "access plus 7 days"
        ExpiresByType image/ico "access plus 7 days"
        ExpiresByType text/css "access plus 2 days"
</VirtualHost>

<VirtualHost *:443>
        ServerName www.site.tld
        ServerAlias site.tld

        suPHP_UserGroup site site
        DocumentRoot /path/to/site/www
        <Directory /path/to/site/www>
                AllowOverride All
                Order allow,deny
                allow from all
                Options -MultiViews
        </Directory>

        SSLEngine On
        SSLCertificateFile /etc/ssl/private/site.crt

        ExpiresActive On
        ExpiresByType image/gif "access plus 7 days"
        ExpiresByType image/jpeg "access plus 7 days"
        ExpiresByType image/png "access plus 7 days"
        ExpiresByType image/x-icon "access plus 7 days"
        ExpiresByType image/ico "access plus 7 days"
        ExpiresByType text/css "access plus 2 days"

</VirtualHost>

Running Ubuntu Server Karmic Koala.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

One option is to put the common configuration i separate file, and use the Include directive to have it used in both VirtualHosts.

share|improve this answer
    
I wouldn't recommend any other way. –  troyengel Jul 11 '10 at 16:51

Your Answer

 
discard

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.