Nginx правила перезаписи для поискового контроллера Prestashop 1.7 не работают - PullRequest
0 голосов
/ 05 августа 2020

Я хочу переписать следующую настраиваемую структуру URL-адресов, удобную для поисковых систем:

https://meinshop.de/de/suche/f7_987_Aprilia/f8_1234_Aprilia+RS+125
https://meinshop.de/de/suche/f7_987_Aprilia/

на это:

https://meinshop.de/de/suche?&f[7]=987&f[8]=1234
https://meinshop.de/de/suche?&f[7]=987

, используя следующие правила перезаписи:

#custom search rewrite
        rewrite ^/{FOLDER}de/suche/([a-z])(\d)(\d+)[^/]/?$ /{FOLDER}de/suche?&$1[$2]=$3;
        rewrite ^/{FOLDER}de/suche/([a-z])(\d)(\d+)[^/]/([a-z])(\d)(\d+)[^/]*/?$ /{FOLDER}de/suche?&$1[$2]=$3&$4[$5]=$6;

У меня есть следующая nginx конфигурация для prestashop 1.7:

location ~ "^/{FOLDER}admin(.*?)/" {
    client_max_body_size 100M;
    if (!-e $request_filename) {
        rewrite ^/{FOLDER}admin(.*?)/.*$ /{FOLDER}admin$1/index.php last;
    }
}
location ~ "^/{FOLDER}backoffice(.*?)/" {
    client_max_body_size 100M;
    if (!-e $request_filename) {
        rewrite ^/{FOLDER}backoffice(.*?)/.*$ /{FOLDER}backoffice$1/index.php last;
    }
}
location /{FOLDER} {
    client_max_body_size 100M;

    rewrite ^/{FOLDER}api/?(.*)$ /{FOLDER}webservice/dispatcher.php?url=$1 last;

    #custom search rewrite
    rewrite ^/{FOLDER}de/suche/([a-z])(\d)(\d+)[^/]/?$ /{FOLDER}de/suche?&$1[$2]=$3;
    rewrite ^/{FOLDER}de/suche/([a-z])(\d)(\d+)[^/]/([a-z])(\d)(\d+)[^/]*/?$ /{FOLDER}de/suche?&$1[$2]=$3&$4[$5]=$6;

    try_files $uri $uri/ /{FOLDER}index.php$is_args$args;
    error_page 404 /{FOLDER}index.php?controller=404;

    #location ~ "^/{FOLDER}admin(.*?)/" {
    #   if (!-e $request_filename) {
    #       rewrite ^/{FOLDER}admin(.*?)/.*$ /{FOLDER}admin$1/index.php last;
    #   }
    #}
    
    location ~* \.(gif)$ {
    rewrite ^/{FOLDER}images_ie/?([^/]+)\.(gif)$ /{FOLDER}js/jquery/plugins/fancybox/images/$1.$2 last;
        expires 2592000s;
    }
    location ~* \.(jpeg|jpg)$ {
        rewrite ^/{FOLDER}([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/p/$1/$1$2$3.jpg last;
        rewrite ^/{FOLDER}([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/p/$1/$2/$1$2$3$4.jpg last;
        rewrite ^/{FOLDER}([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
        rewrite ^/{FOLDER}([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
        rewrite ^/{FOLDER}([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
        rewrite ^/{FOLDER}([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
        rewrite ^/{FOLDER}([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
        rewrite ^/{FOLDER}([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
        rewrite ^/{FOLDER}c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/c/$1$2$3.jpg last;
        rewrite ^/{FOLDER}c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /{FOLDER}img/c/$1$2.jpg last;
        rewrite ^/{FOLDER}images_ie/?([^/]+)\.(jpe?g)$ /{FOLDER}js/jquery/plugins/fancybox/images/$1.$2 last;
        expires 2592000s;
    }
    location ~* \.(png)$ {
        rewrite ^/{FOLDER}images_ie/?([^/]+)\.(png)$ /{FOLDER}js/jquery/plugins/fancybox/images/$1.$2 last;
        expires 2592000s;
    }
    location ~* \.(css)$ {
        expires 604800s;
    }
    location ~* \.(js|jsonp)$ {
        expires 604800s;
    }
    location ~* \.(js)$ {
        expires 604800s;
    }
    location ~* \.(ico)$ {
        expires 31536000s;
    }

        location ~* \.(ttf|ttc|otf|eot|woff|svg)$ {
                add_header Access-Control-Allow-Origin *;
        }
    
    location ~ \.php$ {
        #try_files $uri =404;
                try_files $uri /{FOLDER}index.php$is_args$args;
        include /etc/nginx/fastcgi_params;
        {FASTCGIPASS}
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fastcgi_param PATH_INFO $fastcgi_script_name;
        #fastcgi_intercept_errors on;
        
        fastcgi_temp_file_write_size 10m;
        fastcgi_busy_buffers_size    512k;
        fastcgi_buffer_size          512k;
        fastcgi_buffers           16 512k;
        fastcgi_read_timeout 1200;
        <tmpl_if name='php' op='==' value='hhvm'>error_page 500 501 502 503 = @phpfallback{FOLDERMD5};</tmpl_if>
        
    }
}

<tmpl_if name='php' op='==' value='hhvm'>
location @phpfallback{FOLDERMD5} {
    client_max_body_size 100M;
    #try_files $uri =404;
        try_files $uri /{FOLDER}index.php$is_args$args;
    include /etc/nginx/fastcgi_params;
    {PHPFALLBACKFASTCGIPASS}
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_intercept_errors on;
        
    fastcgi_temp_file_write_size 10m;
    fastcgi_busy_buffers_size    512k;
    fastcgi_buffer_size          512k;
    fastcgi_buffers           16 512k;
    fastcgi_read_timeout 1200;
}
</tmpl_if>

Проблема в том, что я получаю 404, когда вызываю настраиваемую структуру URL.

Я ценю каждый намек на как решить эту проблему, я новичок в nginx (управляемый сервер).

Заранее большое спасибо.

...