June 15, 2025·4 min read

How to Set Up 301 Redirects After Changing a URL Slug

Changing a published URL without a 301 redirect means losing your rankings and backlinks overnight. This guide covers when to redirect, how link equity transfers, and the exact syntax for Apache, Nginx, and Next.js.

Every time you change a published URL, you risk losing the search rankings and backlinks the original page has earned. A 301 redirect is the mechanism that prevents that loss — it tells search engines and browsers that a page has moved permanently, and passes virtually all of the original page’s link authority to the new URL.

This guide explains when to use a 301 redirect, how link equity transfers work, and how to implement redirects correctly in Apache, Nginx, and Next.js.

What is a 301 redirect?

A 301 is an HTTP status code that means “Moved Permanently.” When a browser or search engine crawler requests a URL that has a 301 redirect, the server responds with the new URL and the client automatically follows it. Google treats a 301 as a strong signal that the old URL should be replaced in its index by the new one.

The number 301 refers to the HTTP status code, as opposed to a 302 (temporary redirect) or 307 (temporary redirect with method preservation). Using the wrong redirect type is a common mistake: a 302 tells Google the move is temporary, so it keeps the old URL in its index rather than transferring authority to the new one.

When do you need a 301 redirect?

You need a 301 redirect any time you change the URL of a published page that:

  • Has been indexed by Google (appears in search results)
  • Has backlinks pointing to it from other websites
  • Has internal links from other pages on your site
  • Has been shared on social media and accumulated referral traffic

If a page has never been indexed and has no external links, you can safely change its URL without a redirect. In practice, if a page has existed for more than a few days, adding a redirect is the safer choice.

How link equity passes through a 301

Google estimates that a 301 redirect passes approximately 99% of the original page’s PageRank to the destination URL. The ranking signals accumulated by the old URL — its backlinks, click-through history, and engagement signals — transfer to the new one almost completely.

However, redirect chains multiply crawl overhead significantly. If you have a chain like A → B → C, consolidate it to a single redirect from A → C. Google will follow chains up to five hops, but link equity degrades slightly at each hop and crawl efficiency suffers.

How to implement a 301 redirect

Apache (.htaccess)

Add the following line to your .htaccess file, replacing the old and new paths:

Redirect 301 /old-slug /new-slug

For rewriting URL patterns with mod_rewrite:

RewriteRule ^old-slug/?$ /new-slug [R=301,L]

Nginx (nginx.conf)

Add a return directive inside your server block:

location = /old-slug {
  return 301 /new-slug;
}

Next.js (next.config.js)

Next.js handles redirects in the redirects array in next.config.js:

module.exports = {
  async redirects() {
    return [
      {
        source: '/old-slug',
        destination: '/new-slug',
        permanent: true,
      },
    ];
  },
};

Setting permanent: true emits a 301; permanent: false emits a 302. The SlugGenius Redirect Generator outputs the correct syntax for all three formats automatically — paste in your old and new URLs and copy the ready-to-use redirect rule.

How to test your redirect

After implementing a redirect, verify it with one of these methods:

  • Browser: Visit the old URL. You should land on the new URL automatically with no error page.
  • curl: Run curl -I https://example.com/old-slug and confirm the response is HTTP/1.1 301 with a Location header pointing to the new URL.
  • Google Search Console: Use the URL Inspection tool to check how Google sees both the old and new URLs after the redirect is live.

Common redirect mistakes to avoid

  • Using a 302 instead of a 301: Temporary redirects do not pass link equity and do not update the indexed URL. Always use 301 for permanent slug changes.
  • Forgetting to update internal links: A 301 handles external backlinks, but internal links should be updated to point directly to the new URL. Every unnecessary redirect in your internal link structure adds latency and crawl overhead.
  • Redirect chains: If page A was already redirecting to page B and you now redirect B to C, update the original redirect to point directly from A to C.
  • Redirecting to the homepage: Sending crawlers from a specific page to the homepage instead of the actual replacement content is treated by Google as a soft 404 — it does not pass equity and harms the original URL’s standing in the index.

Getting redirects right is a one-time cost that protects the SEO investment you have already made in your existing pages. Use the Redirect Generator to eliminate the guesswork on syntax, and implement the redirect the same day you change any published slug.