Every PrestaShop page gives a 404 error: friendly URLs, .htaccess and how to get them back

Every PrestaShop page gives a 404 error

The home page loads, but clicking any category or product shows “Page not found”, or a 404 from the server with its own design. Sometimes it happens right after moving the shop to another server, enabling friendly URLs or restoring a backup. The products are there, you can see them in the back office, but no customer can reach them. It is almost always the same problem: the server is not translating the friendly URLs PrestaShop generates, and it is fixed in minutes when you know where to look.

Below you will find why it happens, how to tell apart the five most common cases, what to do on Apache and Nginx, and how to check that Google has not been left with the errors.

Why it happens

With friendly URLs enabled, PrestaShop creates readable addresses such as /trainers/27-blue-trail-trainer.html. That file does not exist on the server. What happens is that the server, thanks to some rewrite rules, receives that address and hands it to PrestaShop, which knows which product it is.

PrestaShop’s documentation is clear about it: friendly URLs only work on a server that allows URL rewriting, usually with Apache’s mod_rewrite module, and it warns that enabling them on a server that does not allow it can take the shop offline.

If those rules are missing, wrong or ignored by the server, the home page works (because it is the index file) and everything else gives a 404.

How a PrestaShop friendly URL works
From the address to the product.

The five cases

What you see Usual cause
Everything gives a 404 after moving server The .htaccess file was not copied, because it is hidden, or the new server does not have mod_rewrite
Everything gives a 404 on a server running Nginx Nginx does not read the .htaccess: the rules go in its own configuration
Everything gives a 404 after changing folder or domain The shop URL in PrestaShop does not match the real one
Only some URLs give a 404 A module, a changed route or products with an empty friendly URL
404s since someone touched the .htaccess Rules added by hand that break PrestaShop’s block

How to check each one

  1. Check whether the .htaccess exists in the shop’s main folder. Many FTP programs and file managers do not show files that start with a dot. If it is not there, you have found the cause.
  2. Ask the hosting which server it uses: Apache, Nginx or both. And whether mod_rewrite is enabled. PrestaShop shows a warning in Traffic & SEO when it does not detect rewriting, although the documentation clarifies that the warning can appear and the feature still work, so you have to test.
  3. Check the shop URL in Shop Parameters > Traffic & SEO: the domain, the SSL domain and the base URI, which is the folder. If the shop was in /shop/ and is now at the root, or the other way round, it needs changing.
  4. Turn off friendly URLs for a moment. If everything works with them off, with addresses like index.php?id_product=27, the problem is rewriting, not the products.
  5. If only some pages fail, open one of those products in the back office and check whether its friendly URL is filled in for every language.
How to diagnose 404 errors in PrestaShop
Before changing anything.

Is this happening to you right now?

Leave us the URL and what you are seeing. A technician will look at it today and tell you what it is before touching anything.

We reply within 24 working hours.

How to fix it

On Apache. PrestaShop generates the .htaccess itself. When you save the Traffic & SEO settings, or turn friendly URLs off and on again, it rewrites it with the correct rules. If the file is not created, it is usually because PrestaShop does not have write permission on the main folder. Before regenerating it, save a copy of the current one: if someone added their own rules, such as old redirects, they will need to go back in, always before or after PrestaShop’s block, never inside it.

On Nginx. Nginx does not read the .htaccess. PrestaShop’s rewrite rules have to be in the site configuration, and that is usually done by the hosting or whoever manages the server. It is the typical case of a shop that moves to a hosting with Nginx and “suddenly” stops working.

If the shop URL does not match. It is corrected in Traffic & SEO. If you cannot get into the back office, it is in the ps_shop_url table in the database: domain, SSL domain and physical URI. Then clear the cache.

If someone touched the .htaccess. Compare it with the previous copy or with a regenerated one, and keep only the custom rules that are needed, outside the block PrestaShop manages.

If it is Apache’s MultiViews option. PrestaShop’s documentation mentions that MultiViews can cause problems with friendly URLs and that it can be disabled from the same screen.

What Google saw in the meantime

If the shop has been giving 404s for hours or days, Google has seen it:

  1. In Search Console, in the pages report, check whether URLs marked “Not found (404)” have gone up.
  2. Inspect two or three of the most important URLs and request indexing once it is fixed.
  3. In Performance, compare the days of the error with the previous ones.

A few hours of 404s usually recover on their own as soon as Google crawls again. If it has been days, it is worth requesting inspection of the main categories and watching the report for the following two weeks. If the drop coincides with a migration, also see traffic drop after migrating PrestaShop.

Moving the shop without it happening again

Most of these 404s appear during a move: of hosting, server or folder. A checklist avoids repeating it:

  1. Before moving, save the current .htaccess separately, and note which custom rules it has and what each one is for.
  2. Ask the new hosting which server it uses, whether mod_rewrite is enabled and, if it is Nginx, who adds PrestaShop’s rules.
  3. Copy the hidden files too. Many FTP programs do not transfer them unless the option is ticked.
  4. Check the shop URL in the database before opening: domain, SSL domain and folder.
  5. Clear the cache before the first test.
  6. Test a category, a product, a content page and the cart, not just the home page.
  7. Check Search Console in the following days, in the pages report.

When only some URLs fail

If most of the shop works and only some addresses give a 404, the problem is different:

What fails Usual cause
Specific products The friendly URL is empty in some language, or the product is disabled
All content pages The content page route was changed in Traffic & SEO
Old URLs that brought visits They changed with an update or a new theme and were not redirected
A module’s pages The module was uninstalled or its route changed

For disabled products, the 404 may be correct; what matters is deciding what to do with each one. We explain it in discontinued products in PrestaShop.

What changes when it is done properly

PrestaShop 404 errors or friendly URLs under control
What changes.

Friendly URLs work on any server the shop moves to, the .htaccess is under control and custom rules are documented, so the next move does not bring the shop down again.

The order of work

The order of work to fix 404 errors in PrestaShop
From the 404 to a stable shop.

What breaks if you get it wrong

  • Turning off friendly URLs for good “because that way it works”. Every address changes and Google loses the ones it had.
  • Deleting the .htaccess and regenerating it without saving the custom rules it had.
  • Writing rules inside PrestaShop’s block. They are lost on the next regeneration.
  • Changing product or category routes in Traffic & SEO without redirecting the old ones.
  • Restoring a backup from the old server onto a new one without checking domain, folder and rewriting.

In short

  1. If the home page loads and everything else gives a 404, the server is not translating friendly URLs.
  2. First: check whether the .htaccess exists and whether the server is Apache or Nginx.
  3. PrestaShop regenerates the .htaccess when you save Traffic & SEO; on Nginx the rules go on the server.
  4. The shop URL in PrestaShop has to match the real domain and folder.
  5. Once the error is fixed, check Search Console and request inspection of what matters.

When you cannot do this yourself

Checking whether the .htaccess exists, reviewing the shop URL and regenerating the rules from Traffic & SEO is something you can do. Configuring Nginx, rescuing custom rules from a broken .htaccess, touching the database without the back office and moving a shop without losing a single URL needs someone who knows PrestaShop and the server. That is what we do when your PrestaShop goes down (in Spanish).

Is this happening to you right now?

Leave us the URL and what you are seeing. A technician will look at it today and tell you what it is before touching anything.

We reply within 24 working hours.

Frequently asked questions

Why does only the home page of my PrestaShop work?

Because friendly URLs need the server to rewrite addresses and hand them to PrestaShop. If the .htaccess is missing, the server does not have mod_rewrite or it uses Nginx without the rules, the home page loads and the rest gives a 404.

How do I regenerate PrestaShop’s .htaccess?

By saving the settings in Shop Parameters > Traffic & SEO, or by turning friendly URLs off and on again. First copy the current file so you do not lose custom rules.

Does PrestaShop work with Nginx?

Yes, but Nginx does not read the .htaccess. The rewrite rules have to be in the server configuration, usually with help from the hosting.

Does it affect SEO that my shop gave 404s for a few hours?

A few hours usually recover when Google crawls again. If the error lasted days, check the pages report in Search Console and request inspection of the main categories and products.