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)
13 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.
Great trick, thanks a lot!
This will not work. If you try this, you’ll enter on a infinite loop with an error message from the server -flooding error- or the navigator -firefox detects the loop after a few-, or maybe you’ll get old waiting for an answer… The problem is pretty clear: You’re redirecting to the same server, so it executes again that redirection, so you’re redirecting to the same server, so it executes again that redirection, so you’re redirecting to the same server, so it executes again that redirection, so you’re redirecting to the same server, so it executes again that redirection, so you’re redirecting to the same server, so it executes again that redirection, so you’re redirecting to the same server, so it exec… ¿Is it clear enough? I hope so.
Thanks, just what I needed!
It worked perfectly on my cPanel server. I un-commented the domain's include statement in httpd.conf and created a .conf file with the line above. All other traffic besides the /secure goes to http correctly.
Thanks.. Exactly what I was looking for.
Thanks It saves my time
Thanks alote it saved my time..
Thanks! Find your site when lokking for the syntax
thank you very much ...
Post a Comment