Automatic Product Redirects
Your store can be configured to automatically generate a permanent redirect whenever the URL key of a product or category changes. In the Search Engine Optimization section, the checkbox below the URL key indicates if permanent redirects are enabled. If your store is already configured to automatically redirect catalog URLs, making a redirect is as easy as updating the URL key. The process to create an automatic redirect is the same for both products and categories.
When automatic redirects are enabled and you save a category, all product and category rewrites are generated in real time and stored in database tables by default. This could result in significant performance issues for categories with many assigned products. The solution is to change this default and skip the generation of category/products URL rewrites for products on category save. In this case, product rewrites are generated only for the canonical product URL.
Set Up Automatic Redirects
-
On the Admin sidebar, go to Stores > Settings > Configuration.
-
In left panel, expand Catalog and choose Catalog underneath.
-
Expand the Search Engine Optimization section.
-
Set Create Permanent Redirect for URLs if URL Key Changed to
Yes
. -
When complete, click Save Config.
Automatically Redirect Product URLs
-
On the Admin sidebar, go to Catalog > Products.
-
Find the product in the list and click to open the record.
-
Expand the Search Engine Optimization section and for the URL Key field, do the following:
-
Make sure that the Create Permanent Redirect for old URL checkbox is selected. If not, follow the instructions to enable automatic redirects.
-
Update the URL Key as needed, using all lowercase characters and hyphens instead of spaces.
Create Permanent Redirect for Old URL
-
-
When complete, click Save.
-
When prompted to refresh the cache, follow the links in the message at the top of the workspace.
The permanent redirect is now in effect for the product and any associated category URLs.
Automatically Redirect Category URLs
-
On the Admin sidebar, go to Catalog > Categories.
-
Find the category in the tree and click to open the record.
-
Expand the Search Engine Optimization section.
-
For URL Key, do the following:
-
Make sure that the Create Permanent Redirect for old URL checkbox is selected. If not, follow the instructions to enable automatic redirects.
-
Update the URL Key as needed, using all lowercase characters and hyphens instead of spaces.
-
-
When complete, click Save.
-
When prompted to refresh the cache, follow the links in the message at the top of the workspace.
The permanent redirect is now in effect for the category and any associated product URLs.
Skip Generation of Product URL Rewrites for Category Save
Turning off automatic generation of category/products URL rewrites results in permanent removal of all existing category/product type URL rewrites, which cannot be restored. This could potentially cause unresolved category/product type URL conflicts that will require a manual update of the URL key to resolve.
-
On the Admin sidebar, go to Stores > Settings > Configuration.
-
In left panel, expand Catalog and choose Catalog underneath.
-
Expand the Search Engine Optimization section.
-
For the Generate “category/product” URL Rewrites field, clear the Use system value checkbox and set the value to
No
.Generate “category/product” URL Rewrites - No
-
In the confirmation dialog, click OK to confirm the change and the removal of existing URL rewrites.
Turn off “category/product” URL rewrites -
When complete, click Save Config.