At times we need to run a website over HTTPS only and to retain the traffic coming to the website over HTTP, that needs to be redirected towards HTTPS. Though there are many ways to do so but this method looks easiest to me-
<VirtualHost *:80>
ServerName mydomain.com
RedirectPermanent / https://mydomain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName mydomain.com
# other SSL configuration goes here
</VirtualHost>
If only parts of the website (say /secure) needs to be HTTPS enabled then redirection can be done something like-
RedirectPermanent /secure https://mydomain.com/secure
Saturday, April 11, 2009
Redirect HTTP to HTTPS on Apache
Subscribe to:
Post Comments (Atom)

4 Comments:
Thanks! This was the exact info I was looking for.
Thanks, this post was useful.
Thanks. I spent a couple of hours trying to find the correct mod_rewrite syntax (with no success), but your method worked very with very little fuss.
I think yours is the most easiest of methods. Thanks! I also spent 2 hours searching but yours is just the easiest way out.
Post a Comment