force https for domain

  • Hello,


    just tried those lines in the imscp/domain.tld.conf
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


    But the domain is not always forwarded to https
    Apache has been restarted


    Maybe a suggestion?

  • I also recommend writing changes into .htaccess.


    BTW: In v1.3.x we'll provide HSTS feature, it's already committed into branch.

  • I guess the vhost.conf will be overwritten by i-mscp...

    You're wrong here


    imscp/domain.tld.conf allows the administrator to override directives from the main vhost. But for the http to https rewrite rule, it is not the right place because that file is included in both, the http vhost and ssl vhost.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • Hi,


    when I am right I couldn´t use an .htaccess because seafile is using fastcgi. So the forwarding should be done by apache configuration.
    Is there another way to influence the forwarding?


    Where would be the right place for this configuration as it is actually not possible to use seperate files for port 80 and 443?

  • @BratHuhn



    I was wrong with my previous sentences. You can try something like:


    Code
    1. RewriteEngine On
    2. RewriteCond %{HTTPS} !=on
    3. RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]


    in the /etc/apache2/imscp/<domain.conf> and then reload your apache configuration.


    BTW: You can use the same statement in .htaccess (even if you use fastcgi).



    Source: https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • Those lines did the trick - now it works.
    Btw I was an idiot, those lines were additionally on the false position in the conf-files -.-


    Thanks guys!

  • @BratHuhn


    You'r'e welcome. And don't worry, we feel all like idiots at some points ;)

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206