Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.