i-MSCP 1.3.10 - Rewrite rule in .htaccess - Pattern is compared to fs path instead of URI

  • Hello,


    I have do this in the .htaccess


    Code
    1. RewriteCond %{HTTP_HOST} !^www\. [NC]
    2. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]


    When I call the URL http://v-gn.com/ is works.


    When I call URL http://v-gn.com/index.php I become a Error 404


    The URL show then : https://www.v-gn.com//var/www/…v-gn.com/htdocs/index.php


    Why came "/var/www/virtual/v-gn.com/htdocs/" in the URL. ?(


    Kind regards
    Viktor


    IMSCP: 1.3.11
    System Ubuntu 16.04

    FPM/FastCGI

    - Distribution: Debian | Release: 8.10 | Codename: jessie

    - i-MSCP Version: i-MSCP 1.5.3 | Build: 20180516 | Codename: Ennio Morricone

    - Plugins installed: ClamAV (v. 1.3.0), Mailgraph (v 1.1.1), OpenDKIM (v 2.0.0), PanelRedirect (v 1.2.0) & SpamAssassin (v 2.0.1)

    - LetsEncrypt (v 3.5.0), PhpSwitcher (v 4.0.3), RoundcubePlugins (v 2.0.2)

  • Good evening


    Can you try to add RewriteBase / at top?

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

  • Good evening


    Can you try to add RewriteBase / at top?

    Hallo,


    I have do this.


    Code
    1. RewriteEngine On
    2. RewriteBase /
    3. RewriteCond %{HTTP_HOST} !^www\. [NC]
    4. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]


    but it is not working.


    Every time "/var/www/virtual/v-gn.com/htdocs/" this is in the URL.


    Viktor

    - Distribution: Debian | Release: 8.10 | Codename: jessie

    - i-MSCP Version: i-MSCP 1.5.3 | Build: 20180516 | Codename: Ennio Morricone

    - Plugins installed: ClamAV (v. 1.3.0), Mailgraph (v 1.1.1), OpenDKIM (v 2.0.0), PanelRedirect (v 1.2.0) & SpamAssassin (v 2.0.1)

    - LetsEncrypt (v 3.5.0), PhpSwitcher (v 4.0.3), RoundcubePlugins (v 2.0.2)

  • @Viktor


    Awaiting for next i-MSCP version, you can use:

    Code
    1. RewriteEngine OnRewriteCond %{HTTP_HOST} !^www\. [NC]RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    The problem


    Due to a change made in newest i-MSCP versions (usage of rewrite engine to setup fcgi handler for PHP scripts only when necessary and avoid unwanted output when a inexistent PHP script is requested), the value compared to the pattern in your rewrite rule is the fs path. This is due to the fact that the URI has been mapped early to the fs path. This will be fixed in version 1.3.12. In that version, We'll avoid usage of the rewrite engine in vhost files and in place, we'll use something like:


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

  • Hallo,


    I have test it again and I think now ist is working.


    I use now this .htaccess.


    Code
    1. RewriteEngine On
    2. RewriteBase /
    3. RewriteCond %{HTTP_HOST} !^www\. [NC]
    4. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    5. RewriteCond %{SERVER_PORT} !^443$
    6. RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]


    With IMSCP 1.3.11 on Ubuntu 16.04 it's works.


    On my Live Server with IMSCP 1.3.10 von Debian 8 it's also work.


    Kind regards
    Viktor

    - Distribution: Debian | Release: 8.10 | Codename: jessie

    - i-MSCP Version: i-MSCP 1.5.3 | Build: 20180516 | Codename: Ennio Morricone

    - Plugins installed: ClamAV (v. 1.3.0), Mailgraph (v 1.1.1), OpenDKIM (v 2.0.0), PanelRedirect (v 1.2.0) & SpamAssassin (v 2.0.1)

    - LetsEncrypt (v 3.5.0), PhpSwitcher (v 4.0.3), RoundcubePlugins (v 2.0.2)

  • A fix has been added in our development branch. See https://github.com/i-MSCP/imsc…c85aaef8d2df21b56839e5477
    This fix will be part of next release.


    Thank you for your report.


    Thread closed.

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