Redirect Http to Https

  • Hi there,


    at the moment I am using .htacces and mod rewrite to redirect my pages from http://... to https://...


    This worked fine for me for all pages i am using ssl.


    Today I installed a cloud software called seafile. After configuring apache to work as proxy I have no chance to redirect from http to https (because there is only one config in /etc/apache2/imscp). (https://github.com/haiwen/seaf…eploy-Seafile-with-apache)


    Is there a chance to get an option in the interface to redirect http allways to https?
    It would also be great to generate more than just one conf in /etc/apache2/imscp - maybe three: nonssl, ssl and both


    Yours Stefan


    (Created a ticket: http://trac.i-mscp.net/ticket/951)

    Edited once, last by UncleSam ().

  • In the meantime you can put this in the config:

    Code
    1. <If "%{HTTPS} == 'off'">
    2. RewriteEngine On
    3. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}
    4. </If>

  • In the meantime you can put this in the config:

    Code
    1. <If "%{HTTPS} == 'off'">
    2. RewriteEngine On
    3. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}
    4. </If>


    Thanks for the answer.
    I tried your solution but its not working (Invalid command '<If', perhaps misspelled or defined by a module not included in the server configuration)

  • Oh well, I see. It's just since Apache 2.4...


    You can use this, it's not as performant as the other one, but works:

    Code
    1. RewriteEngine On
    2. RewriteCond %{HTTPS} off
    3. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}