Jump to content

[BUG?] Product Images 404 on Nginx When Enabling Friendly URLs – Only Works When Disabled


Recommended Posts

Hi all,

I’m running PrestaShop 8.1.x on an Nginx webserver (no Apache, no .htaccess).
Everything works fine out of the box, including all product images, as long as “Friendly URLs” are disabled in the back office.

However, as soon as I enable Friendly URLs (SEO & URLs > Friendly URLS), all product images in the frontend return 404 errors.
The admin panel continues to show all images just fine.

My setup:

OS: Debian 12

Webserver: Nginx (no Apache)

PrestaShop version: 8.1.x

PHP: 8.2

Root path: /var/www/myshop

Images exist: Verified in /img/ and subfolders, with correct permissions

What I tried:

Used the official PrestaShop Nginx config recommendations:

location ~* \.(jpg|jpeg|gif|png|webp|svg|ico|css|js|woff2?|ttf|eot|otf)$ { try_files $uri $uri/ /index.php?$args; access_log off; expires 30d; } location / { try_files $uri $uri/ /index.php?$args; }

Regenerated thumbnails after enabling Friendly URLs

Cleared the PrestaShop cache

Checked all file and folder permissions (www-data owns everything under /var/www/myshop/img)

Product image URLs look like /24-large_default/product.jpg, which do not physically exist but should be routed by PrestaShop (and work fine on Apache)

Symptoms:

Friendly URLs OFF: All product images display correctly.

Friendly URLs ON: All product images in the frontend are 404 Not Found.
Example: /24-large_default/test.jpg = 404
But: /img/[email protected] = OK

What am I missing?

Is there a missing rewrite or special config for Nginx to let PrestaShop handle these virtual image URLs when Friendly URLs are enabled?

Are there extra location rules or something for PrestaShop 8.x that aren’t in the official docs?

Anyone running PrestaShop 8.x with Nginx and Friendly URLs with working product images? Please share your config!

Any advice, working Nginx configs, or pointers are very welcome – this seems like a really common stumbling block!

Thanks in advance!

Link to comment
Share on other sites

This issue is a common pain point when running PrestaShop on Nginx.

PrestaShop’s clean URLs and image routing are natively designed for Apache, which automatically handles all necessary rewrite rules through .htaccess. On Nginx, equivalent rules must be configured manually in your server block—otherwise, friendly URLs for products and images often return 404 errors, as you’re experiencing.

For most small or low-traffic PrestaShop sites, especially if you are not comfortable maintaining custom web server configurations, I recommend using Apache instead of Nginx.

  • Apache “just works” out of the box with PrestaShop, thanks to built-in support for .htaccess and automatic rewrite rule management.
  • It saves time, avoids hidden configuration problems, and reduces maintenance headaches—especially when you upgrade PrestaShop, change URL settings, or install modules that rely on URL rewrites.

Nginx can be a good choice for high-traffic, high-performance scenarios or for users with experience in server administration, but for most shop owners with modest traffic, the potential headaches outweigh the benefits.

If switching to Apache is an option for your hosting environment, it will almost always provide a smoother experience with PrestaShop. Otherwise, you’ll need to carefully manage and update Nginx rules any time your URL structure changes.

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...