Jump to content

PrestaShop 1.7.7.2 on NGINX friendly URLs not working


ArnasL

Recommended Posts

Hello everyone,

Currently I am trying to configure NGINX server for PrestaShop 1.7.7.2 store and I can't make friendly urls to work. I am using this nginx config for my server - https://devdocs.prestashop.com/1.7/basics/installation/nginx/

 

For example I can access homepage in both english and lithuanian language, but if I go to product/category/cms page - I get 404 Error page not found. I can't understand what's the problem. Is PS 1.7.7.2 fully compatible with nginx server? Also I have read that has been problems in the past with product combinations and ajax request with NGINX server. Are these issues are resolved?

 

PS: 1.7.7.2

PHP-FPM: 7.3

NGINX: 1.18.0

OS: Ubuntu 20.04

 

Thanks for help.

Link to comment
Share on other sites

  • 3 years later...

Now on 2024 I have not found a clear answer for this problem, so I'm contributing with my cents:

I was running Prestashop locally on localhost/myprestashop, so the recommended nginx config doesn't work as expected. When I change Prestashop to run purely on localhost/ (in alternative port in my specific case, localhost:81/), it works perfectly.

Going deep, the magic lines of nginx are:

  root /var/www/myprestashop

  # Redirect pretty urls to index.php
  try_files $uri $uri/ /index.php$is_args$args;

  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;

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...