Prestashop 1.7 muitos redirecionamentos na loja frontend

1

Continuo recebendo ERR_TOO_MANY_REDIRECTS ao tentar navegar para a loja de front-end de um site do Prestashop 1.7. No entanto, é bom quando vai para o backend de administração.

Todas as sugestões seriam úteis.

O site está sendo executado com Nginx, PHP-FPM7, MariaDB.

Arquivo de configuração do Nginx abaixo:

upstream examplecoukbackend {
        server unix:/var/run/php-fcgi-examplecouk.sock;
}

server {
        listen 80;
        server_name example.co.uk;
        return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;

    ssl_session_timeout 24h;
    ssl_session_cache shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:RSA+3DES:AES128-SHA:!ADH:!AECDH:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_certificate /etc/letsencrypt/live/example.co.uk/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.co.uk/privkey.pem;

    server_name example.co.uk;
    root /var/www/vhosts/example.co.uk/htdocs; 
    access_log /var/www/vhosts/example.co.uk/access.log;
    error_log /var/www/vhosts/example.co.uk/error.log;

    index index.php index.html;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        auth_basic off;
        allow all;
        log_not_found off;
        access_log off;
    }

    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 1;
    gzip_buffers 16 8k;
    gzip_http_version 1.0;
    gzip_types application/json text/css application/javascript;

    rewrite ^/[a-zA-Z][a-zA-Z]/(index\.php.*)$ /$1 last;  #Remove language code when index.php is called directly
    rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
    rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
    rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
    rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
    rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;

    location /admin/ {                           #Change this to your admin folder
        if (!-e $request_filename) {
            rewrite ^/.*$ /admin/index.php last; #Change this to your admin folder
        }
    }

    location / {
        if (!-e $request_filename) {
            rewrite ^/.*$ /index.php last;
        }
    }

    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.*)$;
        try_files $uri =404;
        fastcgi_keep_conn on;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass examplecoukbackend;  #Change this to your PHP-FPM location
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Arquivo de log abaixo, IPs e nome de domínio generalizado:

2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/([0-9])(-[_a-zA-Z0-9-])?(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/([0-9])([0-9])(-[_a-zA-Z0-9-])?(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-])?(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-])?(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-])?(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-])?(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-])?(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-])?(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: 1 "^/c/([0-9]+)(-[._a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk" 2017/01/08 21:58:00 [notice] 21867#21867: *1 "^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$" does not match "/index.php", client: 0.0.0.0, server: example.co.uk, request: "GET /index.php HTTP/1.1", host: "example.co.uk"

    
por Adam Birds 08.01.2017 / 16:30

4 respostas

1

Um problema aqui é este bloco:

location / {
    if (!-e $request_filename) {
        rewrite ^/.*$ /index.php last;
    }
}

Deve-se usar isto em vez disso:

try_files $uri $uri/ /index.php;

E, em seguida, para o seu administrador:

location /admin/ {                           #Change this to your admin folder
    if (!-e $request_filename) {
        rewrite ^/.*$ /admin/index.php last; #Change this to your admin folder
    }
}

Você pode usar isto:

location /admin/ {
    try_files $uri $uri/ /admin/index.php;
}

No entanto, essas alterações podem não resolver seu problema.

    
por 08.01.2017 / 20:35
0

Provavelmente, o URL principal no Prestashop está configurado incorretamente.

Da documentação:

  • Main URL. By enabling this, you indicate that you want all the other URLs for this shop to redirect to this main URL

Se você configurar http://example.com no Prestashop, mas configurar o nginx para redirecionar todas as solicitações HTTP para HTTPS, você receberá esse loop de redirecionamento.

Certifique-se de configurar o URL principal em Prestashop para o URL para o qual o seu httpd redireciona.

    
por 29.11.2017 / 12:17
0

se você tiver esse problema apenas na frente da loja, então você deve ir para SET UP URLS- > Redirecione para o URL canônico e defina-o como sem redirecionamento

    
por 14.09.2018 / 20:28
-1

Eu tenho o mesmo problema quando movo meu prestashop de local para on-line. Eu resolvi remover. Todo o conteúdo do arquivo .htaccess. Eu acho que o problema surge devido conflitos entre reescrever regras em um. Htaccess e nginx config.

Eu uso esse link do nginx.conf e removo o conteúdo do .htaccess. O erro HTTP 301 desapareceu.

    
por 29.11.2017 / 11:52