Creating a redirect in Magento 2 is fairly easy to do. It can be done straight from the admin panel, which makes it even easier! You can either create a 301 or a 302 redirect.
301 vs 302 redirect
There are 2 types of redirects that are very important to distinguish from each other if you are looking at it from the SEO point of view. Essentially these 2 redirects do exactly the same, which is redirecting an old to a new URL, but the way Google treats them is very different. A 301 redirect tells google that the redirect you’re making is permanent. In other words: the olURLrl will never come back and the new URL is the permanent new URL. A 302 redirect tells google the redirect itself is only temporary, and the original URL will eventually return to be in use.
Now, the big SEO difference is is that with a 301 redirect, Google passes all SEO benefits from the old URL on to the new URL. It does this because you are saying: the old URL/page is now located at the new URL but serves the same purpose. With a 302 redirect, Google won’t pass the old SEO rankings/backlink benefits on to the new URL. This essentially means it will be “brand new” to Google, and will not get the rankings of the old page. This is why you need to know the difference between these two redirects.
Create 301 or 302 Redirect in Magento 2
To create these redirect rules in Magento 2 straight from the admin panel. Follow these steps.
- Log in to the admin panel.
- Navigate to Marketing -> SEO & Search -> URL Rewrites.
- Click “Add URL Rewrite” button.
- Select “Custom” if you want a custom redirect, else choose either “for category”, “product” or “CMS Page”.
- Select the proper store view you want the redirect to apply for.
- In the “Request path” You need to specify the old URL that needs to be redirected
- In the “Target path” You need to specify the new URL that the redirect needs to point to.
- Then you need to specify the redirect type which is either a 301 or a 302.
- Click the save button & Clean the cache/Reindex Magento.
So there you have it. The most easiest way to create redirect rules in Magento 2 from the admin panel. You can also add redirects via .htaccess but that does require some developer knowledge.