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.

how is it possible to toggle between http and https? I want to handle it from .htaccess

.htaccess

RewriteCond %{HTTPS}            !=on
RewriteCond %{HTTP_HOST}        ^(secure)\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$              https://%1.%2/$1 [L,R=301]

httpd.conf

 <VirtualHost *:80>
        ServerName domain.com
        ServerAlias *.domain.com
        DocumentRoot /var/www/domain.com
</VirtualHost>

<VirtualHost *:443>
    ServerName secure.domain.com
    DocumentRoot /var/www/domain.com

    SSLEngine on
    SSLCertificateFile /var/ini/ssl/public.crt
    SSLCertificateKeyFile /var/ini/ssl/private.key
    SSLCACertificateFile /var/ini/ssl/intermediate.crt
</VirtualHost>

when requesting....

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Why not just add Redirect permanent / https://secure.domain.com/ to your *.80 Virtual Host?

Or if you only want http://secure.domain.com to redirect, then add another Virtual Host for that ServerAlias only.

share|improve this answer
    
Best and easiest solution. –  Carlos May 30 '11 at 12:24
    
So give it an upvote then. :) –  gravyface May 30 '11 at 12:42

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.