Subscribe: RSS
  • For a while we had a customer's site working fine with babel in french (default) and english.

    We recently decided for performance purpose to move to nginx + php-fpm on our plesk 12 server.

    we faced an issue with the assets path and url rewrite.

    First thing was to create new nginx rules for rewrite purpose we started with :


    if (!-e $request_filename){
        rewrite ^/(fr|en)?/?(.*)$ /index.php?cultureKey=$1&q=$2 last;
    }
    
    expires 7d;
    add_header X-UA-Compatible IE=edge,chrome=1;
    gzip_proxied any;
    
    gzip on;


    It was far from perfect and we added new rules at the begining :


    rewrite ^/(fr|en)/assets(.*)$ /assets$2 break;
    
    rewrite ^/(fr|en)/assets/main/css(.*)$ /assets/main/css$2 break;
    
    rewrite ^/(fr|en)/assets/main/js(.*)$ /assets/main/js$2 break;
    
    rewrite ^/(fr|en)/assets/img(.*)$ /assets/img$2 break;
    
    if (!-e $request_filename){
        rewrite ^/(fr|en)?/?(.*)$ /index.php?cultureKey=$1&q=$2 last;
    }
    
    expires 7d;
    add_header X-UA-Compatible IE=edge,chrome=1;
    gzip_proxied any;
    
    gzip on;


    everything was nice, BUT we had trouble with the english version of the site where the gallery thumbs were not displayed.

    this was due to :

    <img class="gal-item" src="/assets/components/gallery/connector.php?action=web/phpthumb&ctx=wen&w=100&h=100&zc=1&far=C&q=90&src=%2Fen%2F%2Fassets%2Fgallery%2F3%2F62.jpg" title="2_Le_domaine_1.jpg">


    If you look at the src parameter, you will see it throw a /en//assets/....

    I tried evereything in my mind, asked Menno Pietersen for ideas, dig again and found a quick and dirty fix.

    I created an output filter as this :

    $output='';
    $t = $input;
    $output = ereg_replace("%2Fen%2F", "", $t);
    return $output;


    and changed my gallery item thumbs template from :

    <a href="[[+image_absolute]]" title="[[+description]]"><img class="[[+cls]]" src="[[+thumbnail]]" alt="[[+name]]" /></a>

    to :
    <a href="[[+image_absolute]]" title="[[+description]]"><img class="[[+cls]]" src="[[+thumbnail:trim2F]]" alt="[[+name]]" /></a>


    This is doing the trick for me as an interim solution.

    I am interrested in any idea on how to properly fix it.

    Have fun !

    Philippe
    • You saved my life - Thank you ;-)
      • My pleasure, Stan smiley