Sign up ×
Server Fault is a question and answer site for 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


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


 <VirtualHost *:80>
        ServerAlias *
        DocumentRoot /var/www/

<VirtualHost *:443>
    DocumentRoot /var/www/

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

when requesting....

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Why not just add Redirect permanent / to your *.80 Virtual Host?

Or if you only want to redirect, then add another Virtual Host for that ServerAlias only.

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

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.