All WordPress HTML Templates Forms & Webhooks AI & Tools
WordPress

Redirects in WordPress: Doing 301s Without Breaking Rankings

A practitioner’s guide to the WordPress redirect: building a 301 map, server vs plugin rules, flattening chains, curl testing and when 410 beats a redirect.

A client came to us after a platform move with a 41% drop in organic sessions over six weeks. The redirect map was in place. Every old URL returned a 301. Looked fine in a browser.

The problem was two hops deep. Every old URL 301’d to the non-www HTTP version, which 301’d to HTTPS, which 301’d again because the target slug had changed in WordPress after the import and the old rule pointed at the pre-import permalink. Three hops, one of them a 302 inserted by a caching plugin’s “fix” for trailing slashes. Google was following them, slowly, and consolidating almost nothing.

Getting a WordPress redirect strategy right is less about choosing the right plugin and more about treating the redirect layer as infrastructure: mapped, versioned, tested, and monitored like anything else that can silently delete your traffic.

Key Takeaways

  • One hop, always. Every old URL should point directly at its final destination, including the correct protocol, host and trailing slash. Chains of two or more hops are the single most common cause of post-migration ranking loss we find.
  • Server or edge beats PHP. On client sites we’ve measured plugin-based redirects at 280 to 650ms TTFB on shared hosting versus 8 to 25ms for the same rule in nginx, because the plugin boots WordPress first.
  • Redirect to the closest equivalent page, not the homepage. Bulk redirects to / get classified as soft 404s and pass nothing.
  • Build the map from real data: Search Console’s full URL export, a Screaming Frog crawl of the old site, and your top 1,000 URLs by impressions. Never from a sitemap alone.
  • Some URLs should return 410, not 301. Expired jobs, deleted products with no replacement, spam-generated archives. A 410 cleans the index faster than a redirect ever will.

What a 301 actually promises

A 301 tells a client the resource has moved permanently and that it should use the new URL from now on. For search engines, that does two things: it forwards ranking signals to the target, and it acts as a strong canonicalisation hint, meaning Google will usually drop the old URL from the index and keep the new one.

Two misconceptions worth killing. First, 302 does not throw away your link equity. Google has been clear for years that temporary redirects pass signals too; they just send a weaker canonical hint, so the old URL tends to stay the canonical one. Second, 301s are cached hard by browsers. Chrome will remember a 301 more or less indefinitely for that user. Ship a wrong 301 to a high-traffic URL and you cannot fix it for people who already hit it. That is exactly why staging tests matter more here than almost anywhere else.

If you genuinely don’t know whether a move is permanent, use 302 and sleep fine. A/B testing or geo-routing: 302. Consolidating two pages forever: 301. If the old URL is a POST endpoint, use 307 or 308 so the method and body survive. That last one bites people redirecting form handlers.

Build the map before you touch anything

The redirect map is a CSV with two columns, old path and new path, and it should exist before a single rule is written. Sources, in order of usefulness:

  1. Search Console, Performance report, Pages tab, 16 month range, export all. This is the list of URLs that actually earn impressions. If a URL is here, it needs a destination.
  2. A full crawl of the live old site with Screaming Frog or Sitebulb before you cut over. Crawl with your own user agent and save the HTML. You will need it to compare content later.
  3. Server access logs for the last 90 days, filtered to 200-status GET requests. This catches URLs with inbound links that never ranked, which sitemaps and crawls both miss.
  4. Your backlink tool of choice, exported by referring domain count. Twelve URLs with real links matter more than 900 tag archives.

Deduplicate, then sort by traffic descending. The top 200 rows get mapped by hand. Everything below that can be pattern-matched with regex, and anything that genuinely has no equivalent gets a decision: nearest category page, or 410. We wrote about the wider process in migrating a static HTML site to WordPress without losing SEO, and the mapping discipline is identical regardless of what you’re moving from.

One rule that has saved us repeatedly: the map stores absolute final URLs, with scheme and host. Not paths. The moment you store paths, someone’s HTTPS rule inserts an extra hop and nobody notices for a month.

Where your WordPress redirect rules should live

You have four layers. They are not equivalent.

Edge (Cloudflare Bulk Redirects, Netlify, CDN rules)

Fastest, and the right place for large static maps from a migration. Cloudflare’s Bulk Redirects handle tens of thousands of source URLs and never touch your origin. The downside is that they’re invisible to anyone working in WordPress, so document them in the repo or your successor will spend an afternoon confused.

Web server (nginx, Apache)

Nearly as fast and version-controllable. Protocol and host canonicalisation belongs here, always, as do high-traffic pattern rules. An nginx map is the cleanest structure for a few thousand one-to-one redirects:

# /etc/nginx/conf.d/redirects.map
/old-services/web-design        /services/web-design/;
/2019/06/launching-canvas       /blog/launching-canvas/;
/products.php?id=42             /shop/widget-pro/;
// nginx.conf
map $requesturi $redirecttarget {
    default "";
    include /etc/nginx/conf.d/redirects.map;
}

server {
    # $request_uri includes the query string, so query-based
    # legacy URLs can be matched exactly in the map above
    if ($redirect_target) {
        return 301 https://example.com$redirect_target;
    }
}

WordPress plugin

A redirect plugin such as Redirection, Rank Math’s redirection module, or Safe Redirect Manager is the right tool for ongoing editorial redirects: a post gets re-slugged, a service page gets merged, marketing kills a landing page. Non-developers can manage them, which is the entire point. Safe Redirect Manager is our default on larger sites because it stores redirects as a post type with a hard cap, which stops the table bloating to 40,000 rows of 404 logging. Redirection’s 404 log is useful during a migration and a liability six months later; turn it off once you’re stable.

Theme or mu-plugin code

For patterns a plugin UI can’t express, a small mu-plugin beats 200 manual rows:

<?php
// wp-content/mu-plugins/legacy-redirects.php
addaction( 'templateredirect', function () {
    if ( ! is_404() ) {
        return; // only intervene when WP has already given up
    }

    $path = untrailingslashit( parseurl( $SERVER['REQUESTURI'], PHPURL_PATH ) );

    // Old date-based permalinks: /2018/04/12/post-name -> /blog/post-name/
    if ( preg_match( '#^/\d{4}/\d{2}/\d{2}/([^/]+)$#', $path, $m ) ) {
        wpsaferedirect( home_url( '/blog/' . $m[1] . '/' ), 301 );
        exit;
    }
}, 0 );

Hooking on is_404() means you never shadow a real page, and the rule costs nothing on normal requests. You still pay the full WordPress boot before this runs, though, so don’t use it for your highest-traffic legacy paths.

The failure modes we keep finding

Chains. Old URL to intermediate to final. Each hop adds latency and dilutes the canonical signal. Googlebot follows up to roughly 10 hops within a crawl but will often requeue instead of following immediately, which stretches consolidation from days to weeks. Fix: flatten the map so every source points at the final absolute URL.

Loops. Usually a plugin rule and a server rule disagreeing about trailing slashes. WordPress’s redirect_canonical adds a trailing slash to non-file URLs. If your nginx rule strips it, you’ve built a perfect infinite loop. Decide the canonical form once, enforce it in exactly one place, and never let two layers both have opinions.

Query strings dropped. Apache’s Redirect directive discards the query string. RedirectMatch with $1 does too unless you handle it. In nginx, rewrite ... last appends the original query string by default but a trailing ? on the target kills it. Test with ?utm_source=newsletter attached, every time.

# .htaccess: preserve the query string explicitly
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^products\.php$ /shop/widget-pro/? [R=301,L]

Pattern redirect that keeps the incoming query string

RewriteRule ^old-blog/(.*)$ /blog/$1 [R=301,L,QSA]

Redirecting everything to the homepage. Google calls these soft 404s and treats them as such. If 600 deleted product URLs all land on /, you get neither the ranking transfer nor a clean deindex. Map to the parent category, or return 410.

Rules placed after WordPress’s own rewrite block. In .htaccess, anything below the # BEGIN WordPress block will often never execute because index.php has already claimed the request. Put custom rules above it, and outside the managed markers so updates don’t wipe them.

Cached redirects. Full-page caches, Cloudflare, and plugins like LiteSpeed Cache will happily cache a 301. Ship a wrong one and it persists after you fix it. Purge after every redirect change, and keep redirect rules out of the cacheable path where you can.

Prove it with curl before anyone else finds out

Browser testing is useless here because of 301 caching. Use curl, which caches nothing, and check the whole chain:

#!/usr/bin/env bash

verify-redirects.sh map.csv (CSV: oldurl,expectedfinal_url)

while IFS=, read -r old expected; do # -w prints every hop's status, so chains are visible, not hidden chain=$(curl -sIL -o /dev/null -w '%{httpcode} %{numredirects} %{url_effective}' "$old") read -r code hops final <<< "$chain" if [[ "$final" != "$expected" || "$code" != "200" || "$hops" -gt 1 ]]; then printf 'FAIL %s -> %s (status %s, %s hops)\n' "$old" "$final" "$code" "$hops" fi done < "$1"

Run it against staging before cutover, then against production within ten minutes of DNS or rule changes. We wire it into CI on larger projects so a redirect regression fails the build. num_redirects greater than 1 is a failure, not a warning.

After launch, the monitoring loop is: Search Console’s Page Indexing report for “Page with redirect” and “Not found (404)” counts, the server’s 404 log for the first 30 days, and a weekly crawl. Expect 404s you didn’t predict. On a 4,000 page migration we typically find 60 to 150 legitimate URLs the map missed, mostly from old PDFs, image paths and pagination.

Watch indexing, not rankings, for the first fortnight. Rankings wobble during consolidation and reading them too early leads to panic edits. If old URLs are still indexed after six weeks, something is wrong with the redirect itself.

When a redirect is the wrong answer

Three cases where we deliberately don’t redirect.

The content is gone and has no equivalent. Return 410 Gone. It is an honest signal and Google drops those URLs faster than it drops redirected ones. In WordPress: statusheader( 410 ); nocacheheaders(); exit; in a template_redirect hook matched against a path list.

Near-duplicate pages that both need to stay accessible. Use rel="canonical". Redirecting a legitimate print view or a filtered archive breaks user journeys for a marginal SEO gain.

Thin pages you want out of the index but live on site. noindex, follow. Author archives, internal search results, tag pages with one post. A redirect here just moves the thin signal somewhere else.

There’s also a performance argument against over-redirecting. Each redirect on a page’s critical path, a hero image, a font, an iframe, delays rendering by a full round trip. If you’re chasing Core Web Vitals, audit your own internal links so they point at final URLs. The same logic we covered in page speed wins that actually move LCP applies here. Internal links should never rely on redirects. Update them in the database with WP-CLI:

# Dry run first, always. --all-tables catches ACF and meta fields.
wp search-replace 'https://example.com/old-services/' \
  'https://example.com/services/' --all-tables --dry-run --report-changed-only

If you’re building the new site on a theme with a proper permalink structure out of the box, you’ll have fewer of these to fix. CanvasWP keeps slugs predictable across its page templates, which cuts down on the re-slugging churn that generates redirects in the first place.

Frequently Asked Questions

How long should I keep 301 redirects in place?

At least a year, and for anything with backlinks, permanently. Google only needs a few weeks to a few months to consolidate signals, but humans, bookmarks, PDFs, old newsletters and other sites’ links keep hitting those URLs for years. The cost of keeping a map file is near zero; the cost of removing it is a 404 on a page someone still links to.

Do redirect plugins slow down WordPress?

A well-written redirect plugin adds a negligible query on normal page views, but the redirect itself is slow because WordPress has to boot before it responds. We’ve measured 280 to 650ms TTFB on redirects handled in PHP versus under 25ms for the same rule in nginx. For migration-scale maps, put the rules at the server or CDN. Keep the plugin for the handful of redirects editors need to manage themselves.

Is it safe to 301 an HTTP URL straight to the final HTTPS URL?

Yes, and you should. One hop from http://old-path to https://www.example.com/new-path/ is better than chaining through an HTTPS rule. Keep a catch-all HTTP to HTTPS rule as a backstop, but make your mapped redirects target the full final URL so they never fall through to it. Add HSTS once you’re confident, so browsers skip the HTTP request entirely.

What about redirecting to a different domain after a rebrand?

Same rules, plus the Search Console Change of Address tool, which only works for site-wide moves where the old site 301s to the new one. Keep the old domain’s DNS and certificate renewing for a minimum of two years. We’ve seen rebrands lose recovered traffic purely because somebody let the old domain lapse in month fourteen.

Will AI search engines follow my 301s?

Most crawlers that power AI answers follow redirects, but they’re less forgiving of chains and far less likely to re-resolve a stale cached URL on a schedule you can predict. One-hop redirects and correct canonicals matter more now, not less. We go into the citation side of this in our piece on answer engine optimisation.

What to do next

Pick your single source of truth today. If you’re mid-migration, that’s a CSV in the repo plus nginx or Cloudflare rules generated from it, with the plugin reserved for editorial changes. If you’ve already launched and your numbers are off, run the curl script against your top 200 URLs from Search Console and count hops. Roughly half of “the migration hurt our SEO” cases turn out to be a chain or a trailing-slash loop that takes an hour to fix once you can see it.

And whatever you do, update the internal links. Redirects are a safety net for other people’s links, not a substitute for your own being correct.

301 redirect seo 410 gone vs 301 redirect flatten redirect chains seo nginx redirect map wordpress redirect map migration csv test redirects with curl wordpress redirect wordpress redirect plugin performance