How to Create Magento 2 URL Redirects: 301 Redirect

How to Create Magento 2 URL Redirects: 301 Redirect

Magento 2 URL redirects enable the reuse of URLs without displaying a specific page. It redirects the URL to a different destination within the Magento site. In Magento, this type of redirection is called a 301 redirect. It is a permanent method for guiding search engine bots and website visitors to a new page. This tutorial will cover effective ways to manage URL redirects in Magento 2. It will help you optimize your website's structure and enhance its performance.

Key Takeaways

  • Discover the importance of URL redirects in Magento 2 for preserving SEO value and preventing 404 errors.

  • Explore the various use cases of URL redirects, from domain transitions to addressing duplicate content.

  • Learn how to implement 301 and 302 redirects in Magento 2 effectively.

  • Understand the additional types of redirects in Magento 2, such as 303, 307, and 410 redirects.

  • Discover best practices for managing redirects for a seamless user experience.

  • Explore the challenges in managing Magento 2 redirects and how to address issues like redirect loops and loss of referral data.

What are URL Redirects in Magento 2?

Understanding URL Redirects in Magento 2 for SEO and User Experience

URL redirects in Magento 2 are crucial to managing your website's URLs and ensuring a seamless user experience. It helps direct users from old or broken links to new ones. It also preserves your site's SEO value and prevents Magento users from 404 error pages. These errors can harm your site's crawling, indexing, and Google ranking.

Use Cases for URL Redirects

1. Transition to a New Domain

It facilitates the transition from an old website to a new domain, such as from abc. tk to abc. com. You can transfer the SEO equity from the old domain to the new one by implementing redirects. It means that the new domain can inherit the rankings and reputation of the old domain.


2. Minimize traffic loss

A domain transition can temporarily drop traffic as search engines reindex your new domain. URL redirects help prevent this by automatically sending visitors from the old domain to the corresponding pages on the new one. This continuity ensures uninterrupted access to your content for your audience.


3. Merging Websites

URL redirects help you merge two or more websites into one. Each website being merged likely has its SEO history, including rankings, backlinks, and domain authority. URL redirects allow you to transfer this valuable SEO equity to the new website. It also helps you transition from Magento 1 to Magento 2 or from other platforms like Shopify to Magento.


4. Site Changes

It helps modify your site's menu, product attributes, and structural updates. It assists in maintaining the integrity of your product listings. Users who have bookmarked specific product pages will still be redirected after updates.


5. HTTP to HTTPS Migration

Redirects are crucial in migrating from HTTP to HTTPS. When you migrate your site to HTTPS, you risk losing your SEO ranking. URL redirects help maintain your ranking by notifying search engines of your content's relocation.


6. Addressing Duplicate Content

Duplicate content can arise from various sources, such as multiple URLs for the same page or variations due to URL parameters. URL redirects allow you to combine these duplicate versions into a single, preferred URL. It ensures that search engines, like Google, only index and rank the canonical version.


7. Aiding in Analytics and Tracking

It also assists in tracking and analyzing the impact of site changes. You can monitor the performance of the new structure and content and track user behavior. It also allows you to assess the success of your upgrades using Magento analytics tools.


Types of Redirects: Magento 301 and 302 Redirects

1. 301 Redirect

A 301 redirect signifies a permanent change in the URL of a page. It communicates to search engines and web browsers that a page has been permanently relocated to a new address. This type of redirect is vital to boost your SEO marketing efforts and ensure that link equity from the old URL is transferred to the new one. It helps maintain search engine rankings and traffic. It also redirects traffic to the new page and attributes ranking factors.


Note: Search engines may require time to recognize and adapt to Magento 301 redirects. When changing a website's domain, pay meticulous attention to the content transfer process.

2. 302 Redirect

302 redirect is a temporary redirection method that temporarily shifts a page or provides temporary access to another URL. Unlike a 301 redirect, a 302 redirect does not transfer link equity. Search engines treat the new location as temporary and index the new URL. It does so while preserving the old URL.


The 302 redirect serves various practical purposes:

  • It facilitates A/B testing to enhance webpage functionality or design.

  • It allows collecting client feedback on a new page without affecting the current site's ranking on Google.

  • It enables updating a webpage while ensuring a consistent browsing experience for visitors.

  • Temporary or seasonal products can be redirected to the nearest alternative to maintain customer engagement.

  • Special offer landing pages can be created temporarily.

When implementing redirects within Magento 2, it is crucial to choose the appropriate type based on your specific needs and objectives. Incorrectly using a 302 redirect for permanent transitions can divide link popularity, negatively impacting search rankings.

3. Additional Types of Redirects

Apart from the 301 and 302 redirects, there are other types of redirects in Magento 2. These include:

1. 303 Redirect

The 303 redirect is primarily employed to redirect users after form submissions in Magento 2. Its purpose is to prevent duplicate form submissions, especially when users refresh a page.


2. 307 Redirect (Temporary Redirect)

The 307 redirect, similar to a 302 redirect, is designed for use with HTTP 1.1. It indicates that the content is temporarily located elsewhere, and the client should continue using the same method for future requests. It is typically employed when content has temporarily moved and will return to its original location shortly.


3. 410 Redirect (Gone)

The 410 redirect informs search engines that a page has been permanently removed and no longer exists. It is utilized when content is deleted without a replacement.

How to Create 301 Redirects in Magento 2

Method 1: Create URL redirects via Magento 2 admin backend

Using the built-in URL rewrite feature, you can easily create redirects in Magento 2. This feature lets you set up redirects for specific URLs without additional extensions or tools.


Start by collecting and documenting all the old URLs and their corresponding destinations. This step is crucial to prevent any unwanted errors. Maintaining a record of these URLs on a Google spreadsheet is recommended for easy reference.

  1. Begin by logging into your Magento 2 admin panel.

  2. Navigate to the Marketing section and select SEO & Search.

  3. From the options available, choose URL Rewrites. Select the type of page that this URL rewrite is. The options are:

Navigating to URL Rewrites Section in Magento 2 Admin Panel

  • Custom Pages
  • Category Pages
  • Product Pages
  • CMS Pages
  1. Click on the Add URL Rewrite button located in the top-left corner.

Adding a New URL Rewrite in Magento 2 Admin Panel

  1. Fill in the details in the settings of the new URL rewrite.
  2. Select Create URL Rewrite and set it to Custom.

Creating a URL Rewrite in Magento 2 Admin Panel

  1. Choose the Store view where you want to apply the URL Rewrite.

  2. In the Request Path field, input the URL of the old page you intend to redirect (excluding the domain name).

  3. Provide the new page URL without the domain name for the Target Path.

Note: This field will auto-populate if you select Create URL Rewrite for a category, CMS page, or product.

  1. Under Select Redirect Type, choose Permanent (301). (Unless you only want to redirect a URL briefly.)

  2. You can include a brief description of 301 redirects in the Description field (this is optional).

  3. Click on Save, located in the top-right corner. Your new URL rewrite will be visible when you return to Magento's URL Rewrite's main screen.

  4. Perform a test to confirm the proper functioning of your 301 redirects.

  • Visit your store's homepage and attempt to open the old web page.
  • Alternatively, you can use Google's search bar for the old URL.
  1. You will be redirected to the new page if the 301 redirects have been successfully implemented.

Method 2: Using .htaccess file

  1. Locate the .htaccess file in your Magento root directory.

  2. Inside the .htaccess file, search for the following code block:

apache
<IfModule mod_rewrite.c>
############################################
## Enable rewrites
Options +FollowSymLinks
RewriteEngine on

  1. Within this code block, add the following line to set up the redirection:
Redirect 301 old_url new_url

Ensure you specify the old and new URLs you want to redirect. For instance:

Redirect 301 /old.html /new.html

Note- This command should use complete URLs, including the domain name.

  1. Save the .htaccess file after making these changes.

  2. Verify the redirection by accessing the old URL. It should now properly redirect to the new URL.

Method 3: Create URL redirects In Magento with third-party extensions

To create redirects in Magento 2, you can use third-party extensions. These extensions provide added functionality and flexibility for managing URL redirects on your website. They come with features such as bulk import/export of redirect rules, advanced redirect options, and analytics for tracking redirect effectiveness.

  1. Open a text editor, MS Excel, or spreadsheet application.
  2. Create a simple CSV (comma-separated values) file.
  3. Select a Redirect. You have various methods, including :
  • Legacy Method: Use this format - old-URL; new-URL.

  • Redirects System 1 Method: This is easier to edit, as it has three columns - old-URL, new-URL, and status_code.

  • Query String-Based Redirects: Ideal for websites using search string queries or for specific scenarios like ending a Google Adword campaign or deleting a product attribute. It allows for the use of wildcards to match similar searches.

Note- Keep in mind that your CSV file should be cumulative. You should update or re-download the existing CSV file when adding more redirects.

Best Practices for Redirects in Magento 2

1. Avoiding duplicate redirects

Multiple redirects to the same page can confuse search engines and undermine your site's performance. To prevent this, conduct regular Magento audits of your URL rewrites. Identify any redundant redirects and combine them into a single redirect.


Monitoring your website's traffic and analyzing user behavior is another useful practice. It can uncover potential duplicate redirects that require attention.

2. Testing and monitoring redirects

Testing and monitoring redirects regularly is important to ensure they are working correctly. You can do this by manually clicking on the old URLs and verifying that they redirect to the new URLs as intended.


Additionally, you can use online tools to check for any broken links or errors in your redirects. By actively testing and monitoring your redirects, you can catch any issues early on and ensure a smooth user experience on your Magento 2 website.

3. Update internal links

To ensure a seamless and efficient browsing experience for your website visitors, you must update your internal links so that they directly point to the new destination. It eliminates the need for customers to go through redirects, which can slightly delay page loading.


Direct links guarantee a smoother browsing experience, elevating user satisfaction. Mobile users benefit from direct links, as they often have slower connections than desktop users.

4. Monitor 404 errors for a seamless user experience

It's crucial to monitor 404 errors and address them proactively to maintain a flawless user experience on your Magento 2 store. It also ensures that your site maintains a positive standing in search engine results, helping you attract more organic traffic. You can use tools like SEMrush, Screaming Frog, Ahrefs, etc., to find the 404 errors and broken links. These tools allow you to make necessary improvements, ensuring your site remains functional and up-to-date.

5. Strategic Deployment of Redirects

Redirects are valuable in managing website changes and improving user experience. However, their excessive use can have adverse effects, potentially slowing down your site. It can lead to higher bounce rates, negatively affecting your site's performance. A balanced approach to redirects ensures the efficient utilization of server resources. Review your redirects regularly to identify and eliminate any outdated or redundant ones to prevent this.

Challenges in Managing Magento 2 Redirects

Managing redirects in Magento 2 can present various challenges that must be addressed for a smooth and efficient website experience. These challenges can impact Magento performance and user satisfaction. Here are some common issues and considerations:

1. Magento 2 Redirect Loops

Magento 2 redirect loops can trap users in a continuous redirection cycle. It happens when conflicting Magento 2 redirect rules lead to browsers endlessly redirecting between multiple pages.


Resolving these loops requires careful rule management to eliminate conflicts and ensure smooth redirection. It is essential for retaining user engagement and preventing disruptions in their journey through your website.

2. Loss of Referral Data in Magento 2 Redirects

Improperly configured redirects can lead to the loss of referral data. When referral data is missing, it becomes challenging to trace the source of your website's traffic in analytics tools. It hinders your ability to make data-driven decisions. Ensure your redirects are set up correctly to retain essential referral information and clearly understand your website's traffic sources.

3. Inefficient Wildcard Redirects

While wildcard redirects can be a time-saving tool, they must be implemented correctly to avoid issues. Improperly configured wildcard redirects may result in unintended redirections and disruptions in user navigation. It's essential to carefully define and test wildcard rules to ensure they accurately route users to the intended content, preventing confusion and usability problems.

4. Conflicting Rules in .htaccess

Conflicting rules in the .htaccess file can result in unexpected redirect behaviors. Regularly review and troubleshoot your .htaccess rules to ensure they are consistent and aligned with your redirection strategy. Maintaining a well-organized .htaccess file ensures seamless and predictable redirections on your Magento 2 website.

5. Ignoring Query Parameters

Neglecting URL query parameters during redirects can lead to users landing on generic pages instead of the specific content they seek. Considering query parameters is essential to deliver users accurate and relevant content following redirection. It also ensures user needs are met and their browsing experience remains seamless.

FAQs

1. What are URL redirects important in Magento?

URL redirects in Magento 2 are essential for optimizing your website's structure and preventing 404 errors. They guide visitors to new pages effectively. It also enables you to transfer the authority, rankings, and backlinks from old URLs to new ones.


2. How do URL redirects impact SEO?

URL redirects are crucial for SEO as they help maintain rankings and transfer link equity. It also ensures that search engines index and rank the canonical version of your pages. It positively impacts your website's SEO performance.


3. What are the common issues associated with 404 errors in page URLs?

404 errors can harm your website's crawling, indexing, and Google ranking. It occurs when users land on non-existent pages. It negatively affects user experience and SEO. 404 errors also increase bounce rates.


4. How can I create a 301 redirect in Magento 2 to improve SEO?

To enhance SEO, create a 301 redirect in Magento 2 by using the admin backend or editing the .htaccess file to smoothly transition from old to new URLs. By implementing 301 redirects in Magento 2, you signal to search engines that the transition from old to new URLs is permanent.


5. What are the potential consequences of ignoring URL redirects?

Ignoring URL redirects can hinder your website's SEO performance, diminish its authority, and create a suboptimal user experience. Implementing proper redirects is crucial for maintaining and enhancing your online presence. It can also result in decreased visibility and organic traffic.

Summary

Implementing Magento 2 URL redirects is essential for a successful website migration. It also preserves SEO value and prevents 404 errors. Choosing the right redirect type and regularly testing and monitoring them ensures optimal performance.


This tutorial covered Magento 2 URL redirects, including their role in SEO, creating 301 redirects, and common challenges in managing them. Consider utilizing an optimized Magento server for a smooth hosting experience and user interface.

Maria Ajnawala
Maria Ajnawala
Technical Writer

Maria has over five years of expertise in content marketing, specialising in Magento insights and industry trends. She excels in creating engaging content that resonates within the Magento community.


Get the fastest Magento Hosting! Get Started