The same PrestaShop page with several URLs in Google: how to tell which one counts and fix it

The same PrestaShop page with several URLs in Google

A duplicate URL in PrestaShop is the same page that can be opened from several addresses: the product page from two categories, the version with the combination in the URL, index.php?id_product=…, the address with or without www. PrestaShop solves almost all of them with the canonical tag, and that works. The failure lies in two places almost nobody looks at. The “Redirect to the canonical URL” option comes out of the box with a temporary redirect (302), and with a temporary one Google may keep showing the duplicate URL. And if you have removed the ID from your URLs, two products can end up sharing the same address, without any report warning you.

Below you will find how to check both things, what each Search Console notice means and what to change.

How to tell whether this is happening to you

1. In Search Console. Go to Indexing > Pages and look at these three reasons:

Search Console notice What it means Do you need to do anything?
Alternate page with proper canonical tag The URL points to another one with its canonical, and Google follows it Almost never. It is the correct behaviour
Duplicate, Google chose different canonical than user Your canonical says one thing and Google has decided another Yes. Contradictory signals
Duplicate without user-selected canonical Two identical URLs and neither says which one counts Yes. The canonical is missing

The first one is the scariest and the one that matters least. In a shop with about 2,000 active products that we reviewed this month, there were more than a thousand URLs under that reason. In a sample of a thousand, 97% were category listings with a different sort order or with more products per page. All of them pointed to the right category. There was nothing to fix there.

Duplicate URL in PrestaShop: what the Alternate page with proper canonical tag notice in Search Console is made of
In a real shop, 97% of the URLs under this notice were category listings with a different sort order. All of them pointed to the right category.

2. The canonical redirect. In Shop Parameters > Traffic & SEO > SEO & URLs, look for the Redirect to the canonical URL option. If it says 302, it is still on the default setting. From the database:

SELECT name, value
FROM ps_configuration
WHERE name IN ('PS_CANONICAL_REDIRECT', 'PS_ROUTE_product_rule', 'PS_ROUTE_category_rule');

PS_CANONICAL_REDIRECT: 0 means no redirect, 1 is 302 and 2 is 301. If PS_ROUTE_product_rule does not contain {id}, continue with step 3.

3. Products sharing a URL. This only happens if your URLs do not include the ID, usually because a friendly URL module removed it. This query returns the addresses used by two or more active products. Replace ps_ with your prefix and 1 with your language and shop ID:

SELECT pl.link_rewrite,
 COUNT(DISTINCT pl.id_product) AS productos,
 GROUP_CONCAT(DISTINCT pl.id_product) AS ids
FROM ps_product_lang pl
JOIN ps_product_shop ps
 ON ps.id_product = pl.id_product
 AND ps.id_shop = pl.id_shop
 AND ps.active = 1
WHERE pl.id_shop = 1
 AND pl.id_lang = 1
GROUP BY pl.link_rewrite
HAVING productos > 1;

Each row is a URL that serves only one product. The other one does not exist for Google or for your customers. In the shop mentioned above, five pairs came up: the version with a different finish had the same URL as the standard one and nobody could reach it.

Why it happens: five ways to reach the same product page

Diagram: five different URLs that open the same PrestaShop product page and point to a single canonical URL
Five ways to reach the same product page. Only one should be in Google.

PrestaShop generates these variants by design, not by mistake:

  1. The category in the URL. The default product route includes the category. A product in three categories can be opened from three paths.
  2. The combination in the URL. Each combination has its own address, with the combination ID inside it. The product page canonical always removes it: we checked it in the PrestaShop 8.2 product presenter code.
  3. The non-rewritten URL. index.php?id_product=12&controller=product keeps working even with friendly URLs enabled.
  4. The domain. http and https, with and without www. PrestaShop does not solve this one; the server does.
  5. Capital letters, trailing slash and the language code when the shop only has one language.

For variants 1, 2, 3 and 5, PrestaShop has two defences: the canonical tag on the page and the redirect to the canonical URL. The redirect only acts on GET requests, never on AJAX, and in development mode it shows a warning instead of redirecting. With value 2 it sends a 301; with any other active value, a 302 (FrontController, PrestaShop 8.2). And PrestaShop 8.2 installs with value 1 (installation configuration).

The URL with the combination is the only one of these that Google is interested in reading: it is the one that shows it the price and availability of each size or colour. For Google to understand it as a variant of the same product, and not as a duplicate, you need to mark up the variants with ProductGroup (in Spanish).

Why does the number matter? Google explains it in its documentation on redirects:

  • A permanent redirect tells Google that the destination should be the canonical URL, and it shows the destination in the results.
  • A temporary one is followed, but not taken as a canonical signal, and Google may keep showing the source URL.

With the default 302 you are telling Google that the duplicate URL is still valid.

URLs without an ID are a different case. PrestaShop puts the ID in the URL precisely so that two products with the same name do not clash. If you remove it, nothing stops two products from having the same link_rewrite. When that happens, the shop serves one and the other silently disappears.

How to fix it

1. Switch the canonical redirect to 301

Shop Parameters > Traffic & SEO > SEO & URLs, set up block: Redirect to the canonical URL → 301 Moved Permanently. Save.

PrestaShop Redirect to the canonical URL option: No, 302 and 301 values of PS_CANONICAL_REDIRECT
Shop Parameters > Traffic & SEO > SEO & URLs. PrestaShop comes with 302; switch it to 301.

If you do not have access to the back office, it is value 2 in PS_CANONICAL_REDIRECT:

UPDATE ps_configuration SET value = '2', date_upd = NOW()
WHERE name = 'PS_CANONICAL_REDIRECT';

If you use the PrestaShop cache (memcached, APC or files), clear it afterwards from Advanced Parameters > Performance.

2. Force a single domain from the server

If the shop responds on http or without www, add this at the beginning of the .htaccess, outside the # ~~start~~ and # ~~end~~ lines. Everything between them is regenerated by PrestaShop when you save the SEO & URLs settings. Replace www.yourdomain.com with yours:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.yourdomain.com%{REQUEST_URI} [L,R=301]

If the shop sits behind Cloudflare or another proxy, %{HTTPS} may always be off and cause a loop. In that case, the condition is based on the X-Forwarded-Proto header, or https is forced from the proxy itself.

3. Give each product its own URL

For each row the step 3 query returned, edit the product that cannot be seen. In the SEO tab, change the friendly URL to one that sets it apart, usually by adding what makes it different: finish, colour or size. Since that product had no URL of its own, there is nothing to redirect.

Run the query again every time you import products. The clashes come back with every bulk import. And if one of the two products is no longer sold, it does not need its own URL: disable it and choose what Google should see, as we explain in what to do with discontinued products (in Spanish).

4. What not to do

Do not block duplicate URLs in robots.txt and do not add noindex to them to choose which one counts. Google advises against it in its guide to consolidating duplicate URLs:

  • a URL blocked in robots.txt can still be indexed, without content;
  • noindex removes it from Google instead of passing its value to the right one.

Redirects and the canonical are the strong signals; the sitemap is a weak one. And signals should not be mixed: the sitemap and the canonical must point to the same URL.

Filter parameters (?q=) are a separate case, with their own article: how to stop PrestaShop filters from being indexed.

What happens when it is done right

We are going to apply these changes to the 2,000-product shop in the example, and we will add here the measured progress of the duplicate notices and indexed pages at 4, 8 and 12 weeks.

What breaks if you get it wrong

  • A domain rule that loops. If the shop is behind a proxy and you use %{HTTPS}, the website stops loading. Test the rule in a private window right after saving it and keep the previous .htaccess at hand.
  • Writing inside the PrestaShop block. Whatever you put between # ~~start~~ and # ~~end~~ disappears the next time someone saves the SEO & URLs settings.
  • Changing the URL of the product that was visible. If in step 3 you rename the one Google already had indexed, you lose its ranking. Rename the one that could not be seen.
  • Changing the whole product route (for example, to remove or add the ID) without redirecting the old URLs. Every address in the shop changes at once. It is a migration-level change, not a settings tweak.
  • Leaving a copied .htaccess in another folder. Some servers also apply the one in the parent folder. If a redirect does not behave, look for a second .htaccess before touching anything else. It has happened to us.

When you cannot do this yourself

You can do it yourself if your shop uses PrestaShop’s default URLs, with the ID: switching the redirect to 301 is a drop-down. You need help if a module removed the ID from the URLs and the query returns many clashes, if the shop is behind a proxy and the domain has to be forced on the server, or if Search Console shows many URLs under “Google chose different canonical than user”. That is part of what we review in our PrestaShop SEO service.

Want to know whether this affects your shop?

Leave us your URL. We review it and tell you what we find and what it is costing you, with no commitment.

We reply within 24 working hours.

Frequently asked questions

Why does PrestaShop generate duplicate URLs?

Because the same product page can be reached from several addresses: with and without www, over http and https, with or without the category in the URL, with the ID or with parameters. If they all respond, Google sees several copies.

What is the canonical redirect in PrestaShop?

It is the Traffic & SEO option that decides what PrestaShop does when someone arrives through a URL that is not the main one. With the 301 redirect enabled, it always takes them to the right address.

Is duplicate content bad for an online shop?

It does not cause a penalty, but Google has to choose one of the copies, splits the links between them and may show the one you do not want. In large shops, it also wastes crawling.

How do I check whether my products have duplicate URLs?

With Search Console’s URL Inspection, which shows which canonical Google has chosen, and by opening the same product page with and without www, over http, and from two different categories.