Website & SSL & redirect

Discussion in 'General' started by thischwa, May 12, 2016.

  1. thischwa

    thischwa New Member

    Hi there,
    I'm using ISPConfig 3.0.5.4 (on Ubuntu 14.04 and apache 2.4.7) and I've created an SSL website.
    I've figured out that ISPConfig builds a vhost file with two virtualhost-entries, one for port 80 and one for 443. That's why the website is running twice, with and without ssl.
    Is there an easy way (with ISPConfig) to redirect the website on port 80 to the website on 443?

    Any hints are welcome.
    Kind regards
    Thilo
     
  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    In 3.1 there's a checkbox for that under Sites > {domain} > Redirect > Rewrite HTTP to HTTPS, but I don't know if that's in 3.0.5.4 offhand. If not, just go to Sites > {domain} > Options and put this in Apache Directives:
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
     
    DDArt and thischwa like this.
  3. thischwa

    thischwa New Member

    @Jesse Norell
    You are my hero-of-the-day!
    Nice solution, works perfect with 3.0.5.4, thank you.
     
  4. sjau

    sjau Local Meanie Moderator

    If you have apache 2.4 better use:

    Code:
    <If "%{HTTPS} == 'off'">
        Redirect permanent / https://www.domain.tld/
    </If>
    
    With redirect permanent you have to enter the actual domain name, however that's what the apache guys recommend: https://wiki.apache.org/httpd/RedirectSSL
    The reason is that the mod_rewrite option could interfere with other rewrites... hence I think they recommend the redirect permanent.
     
    DDArt and thischwa like this.
  5. thischwa

    thischwa New Member

    @sjau
    Important point! Thanks a lot for the explanation.
     

Share This Page