301 vs 302 Redirect: Which One to Use and How to Fix Redirects (Practical Guide)

301 permanent and 302 temporary redirect from an old URL to a new one

Quick answer: Use a 301 when the address change is permanent: it passes the old URL's authority to the new one and is the right choice for changed URLs and domain moves. Use a 302 only for temporary changes, such as maintenance or a test. Avoid chains and loops: every old URL should redirect straight to its final destination, and internal links should point to the new URL.

If you changed URLs, reorganized pages, moved to a new domain or are fixing pages that started returning 404, you will need redirects. The catch is that a badly configured redirect can cause traffic drops, redirect loops and lost rankings on Google.

In this practical guide you will see:

  • What 301 and 302 redirects are (and which one to use)
  • Common mistakes that hurt SEO
  • Ready-to-use examples for .htaccess (Apache)
  • How to generate the rules automatically with a free online tool

What is a 301 redirect?

A 301 is a permanent redirect. It tells browsers and search engines like Google that the page has moved to a new address for good.

When to use a 301

  • A permanent URL change (e.g. /blog/old-post → /articles/new-post)
  • A domain migration (e.g. mysite.net → mysite.com)
  • A permanent fix for pages that started returning 404
  • URL standardization (with or without a trailing slash, www or non-www, http or https)

Simple 301 example in .htaccess

Redirect 301 /old-page https://www.yoursite.com/new-page

SEO tip: for permanent changes, a 301 is the safest way to keep the page's relevance and authority.

What is a 302 redirect?

A 302 is a temporary redirect. It signals that the change is provisional and that the original URL may be used again later.

When to use a 302

  • A page under maintenance (temporarily)
  • Seasonal promotions
  • A/B tests (for a limited time)
  • Campaigns that will be removed later

Simple 302 example in .htaccess

Redirect 302 /page https://www.yoursite.com/temporary-page

Watch out: using a 302 for a permanent change can slow Google down in settling on the correct URL.

Common redirect mistakes (and how to avoid them)

1) Using a 302 when it should be a 301

If the URL changed for good, use a 301. Otherwise Google may keep the old URL in its index for longer.

2) Creating a redirect loop

A loop happens when URL A redirects to B and B redirects back to A. Browsers then show errors like ERR_TOO_MANY_REDIRECTS.

3) Chaining too many redirects

Bad example: A → B → C → D. The right way is to point A straight to D.

4) Redirecting everything to the home page

It looks like a quick fix, but it hurts the user experience and can confuse Google. Whenever possible, redirect to the most equivalent page.

How to fix redirects in .htaccess (Apache)

If your site runs on Apache (very common on shared hosting), .htaccess is the usual place to set up redirects.

Example with RewriteRule (more flexible)

RewriteEngine On
RewriteRule ^old-page/?$ https://www.yoursite.com/new-page [R=301,L]

To avoid typos and generate complete rules (including www and HTTPS standardization), use our generator:

.htaccess generator (ready-made rules)

Use the tool: 301 and 302 redirect generator

To create correct rules without typing them by hand, use our free online tool. You enter:

  • The old URL
  • The new URL
  • The type: 301 (permanent) or 302 (temporary)

Result: the tool gives you the lines ready to paste into your .htaccess.

301/302 redirect generator (online)

Quick checklist after setting up redirects

  • Open the old URL in the browser and check it lands on the right page
  • Avoid A → B → C (shorten chains)
  • Update internal links that still point to old URLs
  • Update or regenerate your XML sitemap

For the sitemap, use the XML sitemap generator.

Frequently asked questions

Can I always use a 301?

No. Use a 301 when the change is permanent. If it is temporary, use a 302.

Do redirects hurt SEO?

Not when they are done right. In practice, a redirect is the correct way to keep a page's relevance when its URL changes.

Where is the .htaccess file?

Usually in the site's root folder (public_html, www or the main folder of the domain). On WordPress, it is normally at the root of the domain.

Conclusion

If you want to keep your traffic and rankings when URLs change, redirects are a must. Use a 301 for permanent changes and a 302 for temporary ones. To avoid mistakes, use the generators to create ready-made rules.

Shortcuts:

More in Web troubleshooting