Home » Magento Guide » What is Magento development? » How to set up 301 redirects in Magento 2

How to set up 301 redirects in Magento 2

Key takeaways

  • A 301 redirect permanently sends visitors and search engines from an old URL to a new one, which preserves link equity and rankings.
  • You can create redirects three ways in Magento 2: the admin panel, the .htaccess file, or a third-party extension for bulk jobs.
  • Preparing a spreadsheet of old and new URLs before you start is the best way to avoid errors during a migration.
  • Choosing the right redirect type and testing afterward keeps your store fast and your SEO intact.

Learn how to write redirect rules, Permanent (301) or Temporary (302), for Magento 2 websites. Much of the procedure and user interface will be familiar to Magento 1 users. This guide walks you through what redirects do, when to use them, and how to set them up without losing the traffic you have worked to build.


Host Magento at full throttle.

Get secure, reliable Magento hosting so you can scale faster.

What are URL redirects in Magento 2?

A URL redirect tells browsers and search engines that the content they want now lives at a different address. It guides users from old or broken links to new ones, preserves your site’s SEO value, and keeps shoppers off 404 error pages. Those errors hurt your store in two ways. They frustrate customers, and they harm your crawling, indexing, and Google ranking.

In Magento, the most common version is the 301 redirect. It is a permanent instruction that points search engine bots and visitors to a new page, and it carries the ranking value of the old URL along with it.

301 vs. 302 redirects, and other types you might use

The redirect type you choose tells Google how to treat the move, so pick carefully.

A 301 redirect signals a permanent change. It tells search engines and browsers that a page has moved for good, and it transfers link equity from the old URL to the new one. This is the type you want for migrations, domain changes, and any permanent URL update.

A 302 redirect is temporary. It shifts visitors to another URL for a while without passing link equity, so search engines keep the old URL indexed. Use it for A/B tests, seasonal landing pages, or short-term page updates. Using a 302 for a permanent move splits your link popularity and can drag down your rankings.

A few other status codes come up less often:

RedirectTypePasses link equity?When to use it
301PermanentYesMigrations, domain changes, permanent URL updates
302TemporaryNoA/B tests, seasonal pages, short-term changes
303Redirect after form submissionNoPreventing duplicate form submissions on refresh
307Temporary (HTTP 1.1)NoContent that moved briefly and will return
410GoneNoPages permanently deleted with no replacement

When you need a redirect

Most redirect work happens during a migration, but the use cases run wider than that. Set up redirects when you:

  • Replatform from another system like Shopify or Magento 1 to Magento 2 and want to keep your organic traffic.
  • Move to a new domain and need to transfer your SEO equity, rankings, and reputation.
  • Migrate from HTTP to HTTPS without losing your ranking.
  • Merge two or more sites and want to combine their backlinks and domain authority.
  • Change your menu, product attributes, or URL structure and need bookmarked pages to keep working.
  • Consolidate duplicate content so Google indexes one canonical version.

The common thread is simple. When a URL changes, a redirect keeps the value of that URL from disappearing.

Before you start: prepare your URL spreadsheet

Do this part first, every time. Collect and document all the old URLs and their corresponding destinations in a spreadsheet before you touch the admin panel. This single step prevents the errors that derail most migrations. For large stores, use a crawler to collect your existing URLs at scale instead of listing them by hand.

If you have thousands of products and limited time, prioritize by revenue. Open Google Analytics, sort your products and landing pages by revenue, and redirect your top earners first. That way the pages that make you money keep working while you handle the long tail.

How to create a 301 redirect in Magento 2

You have three ways to set up redirects in Magento 2. The admin panel works well for a handful of URLs, .htaccess suits developers, and an extension handles bulk jobs during a migration.

Method 1: Create redirects in the Magento 2 admin panel

How to write redirect rules for Magento 2 websites; much of the procedure will be familiar to Magento 1 users.

  1. Log in to your Magento 2 administrative panel.
  2. In the main menu, click Marketing.
  3. In the Marketing menu, click URL Rewrites.
  4. If you are familiar with Magento 1.x, Magento 2 uses the same interface from this point forward. Click Add URL Rewrite.
  5. Leave the Create URL Rewrite drop-down list on its default setting, Custom. Fill the Store, Request Path, and Target Path fields.
    • The Request Path is the original path.
    • The Target Path is the new path corresponding to the new web address. This will serve as the target of the redirect rule.
  6. In the Redirect Type drop-down list, select either 301 or 302, as appropriate.
  7. Click Save. If successful, you will see the message, “The URL Rewrite has been saved.”

To confirm it works, visit the old URL in your browser. You should land on the new page.

Method 2: Edit the .htaccess file

If you prefer to work directly with server files, you can add redirects to your Magento root .htaccess file.

  1. Locate the .htaccess file in your Magento root directory.
  2. Find the rewrite code block:
  1. Add your redirect line inside that block, using complete URLs that include the domain name:

Redirect 301 /old.html /new.html

  1. Save the file.
  2. Visit the old URL to verify it redirects to the new one.

Method 3: Use an extension for bulk redirects

Setting up redirects one by one in the admin panel works for a few URLs. It does not work when a migration leaves you with hundreds or thousands. For that volume, a third-party extension lets you import all of your redirects at once. 

You build a CSV file of your old and new URLs, upload it, and the extension creates every redirect for you. Most bulk tools also add features like advanced redirect options and tracking, which save hours of manual copying.

Best practices for redirects

A clean redirect setup protects both your rankings and your store’s speed. Keep these habits in mind:

  • Avoid duplicate and chained redirects. Multiple redirects pointing at the same page confuse search engines and slow things down. Audit your URL rewrites regularly and combine redundant ones.
  • Update your internal links. Point your internal links straight at the new destination so customers skip the redirect hop entirely. Direct links load faster, which matters most for mobile shoppers on slower connections.
  • Keep your on-page SEO elements intact. Your H1 tags, page titles, and internal linking help you rank. Keep them the way they were before migration so you hold your positions.
  • Use redirects with restraint. Too many redirects eat server resources and slow your site, which raises bounce rates. Review them periodically and clear out anything outdated.

Testing, monitoring, and troubleshooting

Redirects need attention after you set them up, not just during. Test each one by clicking the old URL and confirming it lands where it should. Then watch for problems over time.

Monitor your 404 errors and broken links with tools like Screaming Frog, Ahrefs, or Google Search Console, and fix issues as they surface. A few common challenges to look for:

  • Redirect loops trap users in an endless cycle between pages. They come from conflicting rules, so review your rules to clear the conflict.
  • Lost referral data makes it hard to trace where your traffic comes from. Configure redirects correctly so your analytics stay accurate.
  • Inefficient wildcard redirects can send users to the wrong place. Define and test wildcard rules carefully.
  • Conflicting .htaccess rules create unpredictable behavior. Keep that file organized and review it when redirects misbehave.

Magento 2 redirects FAQs

They optimize your site’s structure, prevent 404 errors, and transfer the authority, rankings, and backlinks from old URLs to new ones.

They maintain your rankings and pass link equity to the new page, and they help search engines index and rank the canonical version of your content.

You risk losing rankings, authority, and organic traffic, and you leave customers hitting dead pages. Proper redirects protect the traffic you already have.

Use a 301 for permanent moves, which is almost always the case during a migration. Save the 302 for temporary changes where you want to keep the original URL indexed.

Magento 2 redirects next steps

Redirects are the safety net that carries your SEO value from old URLs to new ones. Set the right type, document your URLs first, and test your work, and you can change your store’s structure without losing the rankings and traffic behind it.

Start by building that spreadsheet of old and new URLs. Once you have it, pick the method that matches your volume: the admin panel for a few redirects, an extension for a full migration.

Liquid Web’s Managed Magento hosting is built for stores that can’t afford downtime, with infrastructure tuned for Adobe Commerce and a support team available 24 hours a day, every day of the year. Our agency customers run 50+ sites on it, and our team handles the migration so you don’t carry the risk alone. When your site matters, confidence matters. Explore Managed Magento hosting and move your site without the headache.

For 24-hour assistance any day of the year, contact our support team by email or through your Client Portal.

Ready to get started?

Get the fastest, most secure Magento hosting on the market

Additional resources

How to remove index.php from your Magento site url →

Learn how to remove index.php from Magento urls for cleaner links.

How to disable caching in Magento →

Discover how to disable Magento caching for testing and development.

How to configure Magento 2 storefronts →

Explore multiple storefronts for managing different stores from one setup