You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Brian Leader <br...@ideaslive.com> on 2004/06/18 15:48:13 UTC

[users@httpd] Mapping a host name to HTTPS automatically

Hello,

I'm trying to set up my host name to automatically use HTTPS.  For 
example, if my host name is secure.mydomain.com, and the user types 
this url in a browser, I'd like the browser to go to 
https://secure.mydomain.com.  But if they just type mydomain.com, they 
should go to http://mydomain.com.  Is this possible with Apache?


Thanks,

Brian J. Leader
brian@mythicwave.com



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Mapping a host name to HTTPS automatically

Posted by Robert Andersson <ro...@profundis.nu>.
Brian Leader wrote:
> For example, if my host name is secure.mydomain.com, and the user
> types this url in a browser, I'd like the browser to go to 
> https://secure.mydomain.com.
> But if they just type mydomain.com, they should go to
> http://mydomain.com.  Is this possible with Apache?

Well, yes. Assuming Apache 2, something like this should work:

    Listen 1.2.3.4:80
    Listen 1.2.3.5:80
    Listen 1.2.3.5:443

    NameVirtualHost 1.2.3.4:80
    NameVirtualHost 1.2.3.5:80

    <VirtualHost 1.2.3.4:80>
        ServerName mydomain.com
        ...
    </VirtualHost>

    <VirtualHost 1.2.3.5:80>
        ServerName secure.mydomain.com
        Redirect / https://secure.mydomain.com
    </VirtualHost>

    <VirtualHost 1.2.3.5:443>
        ServerName secure.mydomain.com
        ...
    </VirtualHost>

If it doesn't make sense, look up each directive in the docs.

Regards,
Robert Andersson

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org