Magento 2 Tutorials

How To Write Redirect Rules In Magento 2

Disclaimer: Magenticians does not necessarily agree with the views expressed in this guest post. They are presented to bring to light all diverse views in the Magento and general ecommerce community.

Magento 2 offers some options that help to optimize the SEO of your Magento 2 store. Redirects are the most common approach developers use in web applications. Redirect usually means a rule or set of rules which helps to forward the user from one URL to another URL. When the rule goes into effect, any link that points to the targeted URL is redirected within seconds. URL redirection also makes your existing URLs more search engine friendly.

In Magento 2, you can easily write the Redirect Rules by using the Magento 2 Admin Panel. Let’s take the following steps to redirect a custom URL to our targeted URL:

Step 1: Login to your Magento 2 Store Admin Panel.

Magento 2 Admin Login

Step 2: From the left sidebar, click “Marketing“.

Magento 2 Admin

Step 3: Under the “SEO & Search” menu, tap “URL Rewrites“.

Magento 2 Admin

Step 4: Click “Add URL Rewrite” button.

Magento 2 URL Rewrite

Step 5: Select “Custom” from the drop-down list of the “Create URL Rewrite.”

Create URL Rewrite Magento 2

Step 6: Select your default store view from the drop-down in “Store” field.

Magento Store View

Step 7: In the “Request Path” field, enter the Requested URL. (Requested URL is the previous URL which will redirect to the targeted URL)

url rewrite Magento

Step 8: In the “Target Path” field, enter the Targeted URL which will serve as the target of the redirect rule for Requested URL.

Create URL Rewrite

Step 9: Select either “Temporary (302)” or “Permanent (301)” in the “Redirect Type” using the drop-down list.

Redirect 301 Magento 2

Step 10: Tap “Save” button when you are done and you will see the success message “The URL Rewrite has been saved“.

Add URL Rewrite Magento 2

The above is a simple guide to write a URL Redirect Rule in Magento 2. This is a good practice to make your Magento 2 Store more SEO friendly and also helps to point your old URLs to the new ones so the user can stay longer on your website. If you have any question related to this tutorial, feel free to share your point in the comments section.

Subscribe Newsletter

Subscribe to get latest Magento news

40% Off for 4 Months on Magento Hosting + 30 Free Migration