httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Pasher <>
Subject Re: [users@httpd] Adding Virtual Hosts for SSL / 443
Date Fri, 18 Dec 2009 22:51:47 GMT
Carlos Williams wrote:
> I have a server up and running with Apache  2.2.14-2. Right now in
> apache my Document Root is set as /srv/http and this takes you to
> www.mydomain.tld. This is perfect on port 80 but I have a subfolder in
> my Document Root called 'webmail/'. When I access the webmail
> subfolder, I want to do this over port 443 (SSL). My question is how
> do I keep my main site as follows:
> www.mydomain.tld (http)
> www.mydomain.tld/webmail (https)
> Also if someone goes to www.mydomain.tld/webmail on port 80, it
> redirects to port 443.

I think you'll be better off and less likely to get confused in the 
script if you break out both HTTP and HTTPS into VirtualHost containers, 
then add some rewrite rules to handle the redirect. Something like this 
(bare bones, untested, substitute for your real IP address on 
the box).

Listen 443

    ServerName www.mydomain.tld
    DocumentRoot /srv/http

    RewriteEngine on
    RewriteRule ^/webmail(/?.*)  https://www.mydomain.tld/webmail$1 [R,L]

    ServerName www.mydomain.tld
    DocumentRoot /srv/http

    SSLEngine on
    SSLCertificateFile "/path/to/my/ssl.crt"
    SSLCertificateKeyFile "/path/to/my/ssl.key"

If you don't understand the SSL directives, I highly recommend 
consulting the docs instead of blindly copying and pasting. You can get 
fancier and also use a rewrite rule to push HTTPS traffic back to HTTP 
if it doesn't start with /webmail.

Justin Pasher

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message