Magento Tutorials

How to Create URL Redirect in Magento

In Magento, sometimes you need to change (rewrite) an existing URL into a new one. The reason may be:

  • The old URL is not user-friendly
  • There’s a typo in the old URL
  • You have duplicate content issues

In those cases, permanently redirecting the old URL into a new one is necessary to make your site become more well-structured and perform good in SEO as well as look good in customers’ eyes. This guide is gonna walk you through how to create URL redirects in Magento via Magento backend and the .htaccess file.

Create URL redirects via Magento backend

Using the built-in URL rewrite feature, you can redirect any URL into a new one by going into your Magento 2 backend and navigate to: Marketing > SEO & Search > URL Rewrites.

Click on Add URL Rewrite.

In the Add New URL Rewrite configuration panel that follows, you’ll have the following options:

  • Create URL Rewrite: Choose the type of page that this URL rewrite is for. Available options are: Custom/For Category/For Product/For CMS page. Note that you’ll need to select a specific category or product or CMS page whose URL you want to redirect.
  • Store: Select the specific view where the rewrite applies.
  • Request Path: Enter the URL of the page to be redirected (the old URL), without the domain name.

E.g., test/old.html

  • Target Path: Enter the URL of the destination page (the new URL), without the domain name (for internal URLs) or with full domain name (for external URLs). Target path will be automatically filled for you if you chose For category, For product, or For CMS page at the Create URL Rewrite setting.

E.g., test/new.html (internal URL) or http://different-website.com/test/new.html (external URL)

  • Redirect Type: Select Permanent (301). Unless you really only want to redirect a URL for a short period of time, you should always choose 301 redirect. It’s good for SEO
  • Description: the purpose of the rewrite. Descriptions are for your own reference and won’t be shown to crawlers.

Click on Save when you’re done and you should see your new URL rewrite shown up on the list.

Magento 2 Import Export URL Rewrites

Admins just take some minutes to import and export URL rewrites data via a CSV file right from the Magento 2 backend.

Create URL redirects using .htaccess

Additionally, you can also edit the default .htaccess file in your root Magento directory to redirect URLs.

Find the following codes in your .htaccess:

<IfModule mod_rewrite.c>


############################################

## Enable rewrites


    Options +FollowSymLinks

    RewriteEngine on

And add:

redirect 301 old_url new_url
## urls use relative paths
## for example: redirect 301 /old.html /new.html

And that’s it! Now go to your old URL and check if it’s been properly redirected to the new URl and you should be all set.


Related posts:
How to Change Base URLs in Magento 1 & 2
Why and How to add Canonical URL Magento instead of 301s or 302s?

Dom

A knowledge craver who always strive to be wiser everyday.

Subscribe
Notify of
guest

2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Damon Moats
Damon Moats
5 years ago

A very informative article, enabling URL rewrite’s really contributes in improving search engine optimization of Magento store, there’s another really good tutorial for this magenticians. I found it really helpful and to the point, do have a look at it too. Thanks

timothyferriss
timothyferriss
9 months ago

Visitors who reach the original URL eggy car will be automatically redirected to the new URL given in the redirect settings after the redirect has been saved.