How to redirect HTTP to HTTPS in Apache with mod_rewrite?

I'd like to force using of https on one of my site. How to redirect HTTP to HTTPS in Apache with mod_rewrite?

asked Aug 13, 2014 by Eric Z Ma (43,500 points)

1 Answer

 
Best answer

You can put these lines to the .htaccess file in the directory from which you would like to redirect HTTPS to HTTP:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
answered Aug 15, 2014 by Eric Z Ma (43,500 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...