Skip to content
SEO & AI Search

301 Redirects: What They Are and How to Set Them Up on Any Website

How to set up a 301 redirect on WordPress, .htaccess, Shopify, Wix, Next.js and Cloudflare, with copy-ready code, testing steps and common mistakes.

ParvesFounder and Creative DirectorUpdated 6 min read
301 Redirects: What They Are and How to Set Them Up on Any Website

Quick answer

A 301 redirect permanently sends visitors and search engines from an old URL to a new one, and tells Google to move the old page's ranking signals to the new address. Use one whenever you change a page's URL, delete a page that has a close replacement, move to a new domain or switch to https. Point each old URL directly at its closest match, avoid chains, and keep redirects in place for at least a year.

Every time a URL on your website changes, something has to tell browsers and search engines where the page went. That something is a 301 redirect. Get it right and your rankings, backlinks and bookmarks follow the page to its new address. Get it wrong, or forget it, and years of SEO work can disappear into 404 errors overnight.

This guide explains what a 301 redirect is, when to use it, and exactly how to set one up on the platforms our clients use most.

What is a 301 redirect?

A 301 is an HTTP status code meaning "moved permanently". When a browser or search engine requests the old URL, the server answers with the 301 and the new address, and the visitor lands on the new page automatically.

Google's documentation on redirects and Google Search explains that permanent server-side redirects (301 and 308) are a strong signal that the new URL should be the one shown in search results.

Code Meaning Use it when
301 Moved permanently A page has a new permanent address. The default choice.
308 Permanent, keeps the request method Same as 301; common in modern frameworks. Google treats it the same way.
302 Found (temporary) A page is temporarily elsewhere, such as during maintenance
307 Temporary, keeps the request method Same as 302 in modern frameworks
410 Gone A page was removed on purpose with no replacement

When do you need a 301 redirect?

  • You changed a page's URL, for example from /our-services/ to /services/
  • You merged two similar pages into one
  • You deleted a product or service that has a close replacement
  • You moved to a new domain, or from http to https, or between www and non-www
  • You redesigned or rebuilt the site on a new platform with a different URL structure

The last one is where most damage happens. Our website redesign and SEO migration checklist covers the full process.

Step 1: Map every old URL to its new home

Before setting anything up, build a redirect map in a spreadsheet with two columns: old URL and new URL.

  1. Collect old URLs from your XML sitemap, a site crawl, Google Search Console's Pages report and your analytics landing pages. Include pages with backlinks.
  2. Match each to the closest new page. A product goes to the same product or its replacement; a blog post to its updated version; a deleted service to the nearest related service.
  3. Mark pages with no match. Let them return 404 or 410 rather than redirecting them somewhere irrelevant.

When we rebuilt this website, old WordPress addresses such as /portfolios/winnies-2/ and /about-us/ were mapped one by one to their new homes, /case-studies/winnies and /about, so each old link lands on the right page in a single hop.

Step 2: Set up the redirects on your platform

WordPress

The easiest route is a plugin:

  1. Install Redirection (free) or use the redirect manager in Rank Math.
  2. Add a new redirect with the old path as the source and the new URL as the target.
  3. Choose 301 Moved Permanently.
  4. For many URLs, use the plugin's CSV import with your redirect map.

Redirection can also log 404 errors, which helps you spot old URLs you missed. If you are deciding between SEO plugins, see our Yoast vs Rank Math comparison.

Apache or LiteSpeed hosting (.htaccess)

Most shared hosting, including Hostinger, uses Apache or LiteSpeed, which read a file called .htaccess in your site's root folder. Back it up before editing.

For single pages:

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

For a pattern, such as moving a whole folder:

RewriteEngine On
RewriteRule ^portfolio/(.*)$ /case-studies/$1 [R=301,L]

To force https and one hostname:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

A typing mistake in .htaccess can take the whole site down, so test immediately after saving.

Shopify

  1. In your Shopify admin, open Online Store, then Navigation, then URL Redirects (or search "redirects" in the admin search bar).
  2. Add the old path and the new target.
  3. For bulk changes, import a CSV.

When you change a product or collection handle, Shopify offers a checkbox to create a redirect automatically. Leave it ticked. More in our Shopify SEO guide.

Wix

Open SEO from the dashboard, then the URL Redirect Manager, and add old and new URLs. Wix also supports importing redirects in bulk.

Next.js and other frameworks

In Next.js, add permanent redirects in next.config:

async redirects() {
  return [
    { source: "/about-us", destination: "/about", permanent: true },
    { source: "/portfolios/:slug", destination: "/case-studies/:slug", permanent: true },
  ];
}

Next.js sends a 308 for permanent: true, which Google treats like a 301.

Cloudflare

If your domain runs through Cloudflare, use Redirect Rules for patterns or Bulk Redirects for long lists. These run before requests reach your server, which is useful when moving between hosts.

Step 3: Test every redirect

  1. Open a sample of old URLs in a private browser window and check they land on the right page.
  2. Check the status code, not just the destination. In a terminal: curl -I https://example.com/old-page/ should show 301 (or 308) and a location line with the new URL.
  3. Run your whole redirect map through a crawler in list mode to check every URL in one go.
  4. Make sure each redirect is a single hop. Two or more hops is a chain.
  5. In Google Search Console, use URL Inspection on a few new URLs and request indexing for the most important ones.

Redirects catch old links from other websites. Your own site should not rely on them:

  • Update menus, footers and in-content links to point straight at the new URLs. Our internal linking guide shows how to audit them.
  • Make sure the XML sitemap lists only the new URLs.
  • Update links in your Google Business Profile, social profiles and ads.

Common 301 redirect mistakes

  • Redirecting everything to the homepage. Google often treats this as a soft 404, and the old page's value is lost.
  • Redirect chains and loops. A redirects to B, B to C, or worse, C back to A.
  • Using 302 for permanent moves. Common with some plugins' default settings. Check the code.
  • Forgetting trailing slash and case variants. /About-Us/ and /about-us may be different URLs on your server.
  • Removing redirects too soon. Google's site move guidance recommends keeping them for as long as possible, generally at least a year.
  • Redirecting through JavaScript. Server-side redirects are faster and clearer for search engines.

What to watch after setting up redirects

For the next four to eight weeks, check Search Console's Pages report for new 404 errors and "Page with redirect" entries, and compare clicks to the redirected pages with the period before. Small dips for a few weeks are normal; a sustained drop means something in the map needs fixing.

Redirects are one part of technical health. For the rest, use our technical SEO audit checklist. And if you are planning a migration or a redesign and want it done without losing rankings, our SEO services team plans and tests redirect maps as part of every site move.

Work with us

SEO Services from The Coral Flow

Get a free SEO health check. Share your website. We send a recorded walkthrough of your top technical issues and the keywords you are closest to winning.

Check my SEO

Frequently asked questions

What is the difference between a 301 and a 302 redirect?

A 301 (or 308) tells search engines the move is permanent, so the new URL becomes the one shown in results. A 302 (or 307) says the move is temporary, so Google may keep showing the old URL. Use 302 only for genuinely temporary changes.

Do 301 redirects lose SEO value?

A correctly mapped 301 to a closely matching page passes its ranking signals to the new URL. Value is lost when pages are redirected to unrelated pages, such as sending every old URL to the homepage.

How long should I keep redirects?

Google's site move guidance suggests keeping them for as long as possible, generally at least a year. In practice, keep them permanently unless they cause problems; old links and bookmarks keep arriving for years.

Should I redirect deleted pages to the homepage?

No. Google tends to treat irrelevant redirects like that as soft 404s. Redirect to the closest relevant page, or let the page return a 404 or 410 if there is no replacement.

What is a redirect chain?

When URL A redirects to B, which redirects to C. Each hop slows the visit and risks signals being lost. Update A to point straight at C.

Written by

Parves, Founder and Creative Director

Leads strategy and creative direction at The Coral Flow in Chennai, across web, search and content for brands in India and abroad.

About the author

Share this guide

Let's talk

Want us to do this for you?

Tell us what you are working on. We reply within one working day with honest advice and next steps.