I am using Magento 2.4.1, PHP 7.4, nginx and varnish and a stock import module that also creates URL rewrites. This part of it is all working fine and the url_rewrite table in the database has the rewrites listed but when browsing my site i get url's like
instead of
(which also works but not showin in the browser address bar).
The category urls work fine as do any products listed on my homepage in a bestsellers block, but not when navigating to a category and then clicking on a product.
I have tried reindexing, resetting the index and reindexing, cleaning and flushing cache, none of it works. I am not in single store mode, URL rewrites have been enabled.
Any ideas how i can sovle this issue?

1 Answer 1


In my case, I found that the rewrites table contained no entry for type category. So the system used the internal one.

This was because I had copied categories and products from my live site in a database import. I should have copied the rewrites too...

Rewrites are only created when you save a category, and only if it detects a change.

Option 0: if like me you migrated the category/product data in a database import, migrate the category and product rewrites too.

Option 1: Changing the seo url-key in category admin and saving, then changing it back and saving again - this will trigger an entry being created in the rewrites table The links were suddenly correct for that category.

This is time consuming but if you use category url-key in your product urls too it's probably the only way.

Make sure you UNTICK the "create rewrites for old URLs" both times

Option 2: insert missing rewrites in the rewrites table direct

If you have many categories and don't have "category in product url" this is quicker.

If you have "category in product url" it might be worth disabling it, saving, doing the changes, then re-enabling it. (only if you don't have history to preserve - but hey, if you do, perhaps back it up then reimport it?)

You'd have to do it per store, if you have multiple stores.

INSERT INTO `url_rewrite` (`entity_type`, `entity_id`, `request_path`, `target_path`, `redirect_type`, `store_id`, `is_autogenerated`) VALUES ( 'category', '21', 'your-url-key', 'catalog/category/view/id/21', '0', '1', '1');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.