How to remove IDs from PrestaShop URLs without losing traffic

You can remove IDs from PrestaShop URLs only with a module or a code change, because the store settings make the {id} keyword mandatory in every URL pattern. Without a module, you can turn on friendly URLs and shorten them (for example, drop the category and EAN code from product URLs), but the number stays. Whatever you change, the most important part is a 301 redirect from every old link to its new address; without it, you lose Google traffic and links from other websites. Below we explain where the numbers come from, what you can set in the back office and how to change your URLs safely.

Why are there numbers in PrestaShop URLs?

Default PrestaShop URLs look roughly like this:

  • category: /12-running-shoes,
  • product: /men/25-73-basic-t-shirt.html,
  • CMS page: /content/4-terms-and-conditions.

The number at the start is the database identifier (ID): 12 is the category, 25 is the product and 73 is the combination, such as a size and colour. PrestaShop identifies the page by its ID; the text after the hyphen is just decoration as far as the store is concerned.

This approach has advantages. Two products can share the same name in the URL, and after you rename a product the old link still works: the store reads the ID and sends the visitor to the current address. The downside is long, hard-to-read links that are harder to remember and look worse in search results and when shared.

Do IDs in URLs hurt SEO?

The number itself does not stop you from ranking. Google recommends simple, descriptive URLs that people can understand (Google's URL structure guidelines), but the URL is only one of many minor signals. A clean /basic-t-shirt.html instead of /men/25-73-basic-t-shirt.html mainly gives you:

  • readability in search results, emails and social media,
  • shorter links that are easier to copy and remember,
  • a consistent look across the whole store.

Duplicate content and broken links are a much bigger SEO problem than the number itself. A badly executed URL change can do more harm than leaving the IDs where they are. That is why the next sections deal with it in detail.

Traffic & SEO settings: what can you change without a module?

The URL settings live in Shop Parameters > Traffic & SEO > SEO & URLs. The path is the same in PrestaShop 1.7, 8 and 9.

Option What it does Recommendation
Friendly URL turns index.php?id_product=25&controller=product into a readable address Yes; the server must support URL rewriting
Accented URL allows accented characters in URLs usually No, so "café" becomes "cafe"
Redirect to the canonical URL how the store responds to an outdated URL; 302 by default 301 once your store is live
Disable Apache's MultiViews / mod_security options for Apache servers only when friendly URLs do not work

On Apache, PrestaShop generates the .htaccess file itself when you save these settings. On nginx, your server administrator has to add the rewrite rules.

Schema of URLs

Further down, in the Schema of URLs section, you set the URL pattern for each page type. Words in curly braces are variables, and the ones marked with an asterisk are mandatory.

Page Default pattern
Product (1.7 and 8) {category:/}{id}{-:id_product_attribute}-{rewrite}{-:ean13}.html
Product (fresh 9 install) {id}{-:id_product_attribute}-{rewrite}.html
Category {id}-{rewrite}
CMS page content/{id}-{rewrite}
Brand brand/{id}-{rewrite}

Without a module, you can drop the category and EAN code from product URLs, rename prefixes such as content to info, or add .html at the end. You cannot remove {id}, though: when you try to save, PrestaShop reports that all mandatory keywords must be included in the route. A store upgraded to version 9 keeps its previous product pattern, so the upgrade itself does not change your URLs.

The friendly URL of a single page

The {rewrite} part is the friendly URL field you will find in the product's SEO tab and in the category and CMS page forms. PrestaShop fills it in from the name, but it is worth shortening: keep the key words and drop filler such as "new" or "sale". With IDs in the URL, changing this field is safe: with the canonical redirect enabled, the store sends visitors from the old link to the new one. Without IDs, every change needs a 301 redirect.

How do you remove IDs from PrestaShop URLs?

There are two ways:

  1. A module that extends the URL handling so the store recognises pages by name alone, and takes care of redirects.
  2. Your own override of the classes responsible for URLs. It works, but every PrestaShop upgrade can break it, and maintaining it falls to you or your developer.

Whichever way you choose, the solution has to handle several situations that never came up while the numbers were there:

  • two products with the same name, such as "basic-t-shirt" in two collections; without an ID, the URL must be unique,
  • conflicts between page types, when a category and a CMS page end up with the same URL,
  • several languages and shops, each with its own URLs,
  • a renamed product, whose old URL must redirect to the new one.

If you would rather not write and maintain this yourself, we can do it for your store as development work: URLs without IDs, 301 redirects from the old links and a check for duplicate addresses, tested on a copy of the store before it goes live.

Duplicate content and 404 errors: what should you watch out for?

Warning: change your URL pattern once, after thinking it through, and on a copy of the store first. Every further change means another batch of redirects and more weeks while Google learns the new addresses.

The most common traps:

  • The same product under several URLs. When the URL contains a category and the product belongs to several categories, PrestaShop with the canonical redirect enabled sends the visitor to the URL with the default category. Without that option, Google sees several copies of the same page.
  • URL parameters. Sorting, filters and pagination add parameters to the URL. Check that your theme adds a canonical tag pointing to the main version of the page.
  • www and non-www, http and https. The store should answer on one address only and redirect the other versions to it with a 301.
  • Disabled products. In the product's SEO tab, you can set a redirection for when the product is offline, for example a 301 to its category, instead of showing a 404 error.
  • New URLs without redirects. Once the IDs are gone, old links from Google, price comparison sites and other websites stop working unless something redirects them.

How do you redirect old URLs with a 301?

A 301 redirect tells search engines that a page has moved permanently and passes its history on to the new URL. Step by step:

  1. Collect your current URLs before the change: from the sitemap, the Performance report in Google Search Console and a site crawler.
  2. Map every old URL to a new one, one to one. Do not redirect everything to the home page; Google treats that much like a 404 error.
  3. Set up the redirects: with a module that does it automatically, or with server rules (Redirect 301 in .htaccess on Apache, return 301 on nginx). With hundreds of products, hand-written rules quickly become unmanageable.
  4. Update internal links in menus, CMS content and product descriptions, so the store does not send visitors through its own redirects.
  5. Regenerate your sitemap and submit it in Search Console. Our guide to the PrestaShop XML sitemap shows how.
  6. Watch the Pages report in Search Console and your server logs, and keep the redirects for a long time. For site moves, Google recommends keeping them for at least a year (Google documentation).

Rankings may fluctuate slightly for a few weeks while Google processes the new URLs. That is normal with any URL change. While you are at it, check that your product and breadcrumb structured data point to the new URLs; our article on stars and prices in Google results covers that.

Frequently asked questions

Will removing IDs from URLs improve my Google rankings?

On its own, usually not by much. The URL is a minor signal, although a readable link can attract more clicks and looks better when shared. What matters most is that the change goes through without 404 errors or duplicate content.

Can I remove IDs in the PrestaShop settings, without a module?

No. In PrestaShop 1.7, 8 and 9, the {id} keyword is mandatory in every URL pattern, and the back office will not let you save a pattern without it. You need a module or your own code override.

If nothing redirects them, they start returning 404 errors and Google eventually drops them from its results. A 301 redirect from every old URL to its new one keeps your traffic, links from other websites and working links in old emails.

Should I remove the category from product URLs?

Usually, yes. A product URL without a category is shorter and does not change when you move the product to another category. Fresh PrestaShop 9 installs no longer include the category in product URLs by default.

Will the change affect my product feed and ads?

Your product feed picks up the new URLs at its next refresh. Old URLs in your ads keep working thanks to the redirects, but it is worth updating them, as each redirect adds a step when the page loads.

Planning to change your store's URLs? Order the change as development work or contact us.

Products in this article

Back to Blog

Loading...
Back to top