How to redirect an HTTP connection to HTTPS in apache webserver

Http connections can be redirected to https with the apache mod_rewrite module, which should be available in every apache installation. Create a file with the name .htaccess in the website root directory which contains the following lines:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

If you use ISPConfig 2 or 3, you can add these lines also in the apache directives field of  the website settings form instead of adding them to a .htaccess file. But the approach with the .htaccess file will work on ISPConfig as well.

facebooktwittergoogle_plusredditlinkedinmail

2 thoughts on “How to redirect an HTTP connection to HTTPS in apache webserver”

  1. Hello ISPconfig team i follow this step but it still doesn’t work can you help me.
    i use ISPconfig3 version 3.0.3.3

    Regard
    veasna

  2. Great tip. It worked perfect to me.
    The only thing I had to do was put those three lines on the bottom of httpd.conf file, and restart my server.
    Thank you very much.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>