Magento 2 Auto Redirects: Avoid 404 Pages in Your Store

The 404 pages are one of the biggest threats for both, the store owners and search crawlers. While the former fear it will stop people from browsing their store, the latter simply can't crawl your websites properly. As a result, the technical part of your Magento SEO is affected along with your rankings. 

That's why you have to avoid 404 pages in your store at all costs. So, in this guide you'll learn how to do that, using default features and Magento 2 SEO Extension

Magento Automatic Redirect on URL Change

Unfortunately, it's not possible to avoid 404 pages completely since you change page URLs constantly. However, you can at least, try to keep them to a minimum. That's why Magneto created auto redirects for products and categories. 

To configure permanent redirects in Magento 2: 

1. Go to Stores > Configuration > Catalog > Catalog > Search Engine Optimization and enable the Create Permanent Redirect for URLs if URL Key Changed option. Don't forget to Save the settings.

create permement redirects fore urls if urls key changed

2. Move to Catalog > Products and choose a product you'd like to change the URL for.

3. Make sure the Create Permanent Redirect for old URL checkbox is selected in the Search Engine Optimization section after you change the URL.

magento permanent redirects

Once you Save a product, you can go to Marketing > SEO & Search > URL Rewrites and check the redirect. 

magento 2 redirects

The same works for categories. Whenever you change a category URL, Magento creates a redirect if you keep the Create Permanent Redirect for the old URL checkbox selected.

Magento Automatic Redirects from Disabled/Deleted Pages

While Magento covers redirects on URL change, it doesn't create them when you disable or delete a page. This time you need to rely on some additional tool, especially if you have an extensive catalogue. That's when Magento 2 SEO Extension comes in handy. 

To enable Magento 2 auto redirects from disabled or deleted pages: 

1. Navigate to Stores > Configuration > Magefan Extensions > SEO > Auto Redirects

2. Enable the corresponding options:

  • Redirect From Disabled Categories
  • Redirect From Disabled Products
  • Redirect From Deleted Categories
  • Redirect From Deleted Products

Note: there is a separate option for CMS pages — Redirect From Deleted CMS Page.

magento auto redirects

Now let's see how the redirects work. 

  • Product — disabled/deleted product -> subcategory (if any) -> main category -> homepage. 
  • Category — disabled/deleted category ->  subcategory (if any) -> main category -> homepage.
  • CMS page — homepage.

Additionally, you can enable Magento auto redirect for products, categories and homepage to canocial URLs. 

redirect to canonical url magento

After you Save the settings you can safely manage your catalog without fearing the redirect issue flagged in Google Search Console. However, there still might be some blank spaces to fill here. 

When you edit the URL of the CMS page or blog pages, there won't be any auto redirects in Magento. So you need to learn how to create redirects in Magento manually.