SEO and marketing

301 redirect

Definition

A 301 redirect is an HTTP response telling browsers and search engines that a URL has moved permanently to another one. Visitors land on the new URL, and Google treats the redirect as a strong signal to index the new address instead of the old one.

301 redirect, SEO and marketing

Changing a page's URL without telling search engines is like moving without forwarding your mail: links pointing to the old URL land on a 404 error, and the page starts over from scratch. A 301 redirect prevents that loss. The server responds with a 301 (Moved Permanently) status code along with a Location header giving the new URL, and the browser loads it automatically.

Permanent or temporary: the different codes

CodeTypeEffect for Google
301, 308PermanentStrong signal that the target should become the canonical URL
302, 303, 307TemporaryThe old URL may stay in the results
Instant meta refreshTreated as permanentOnly for cases where the server can't redirect
JavaScript redirectLast resortOnly seen if the page renders successfully

Google recommends a permanent redirect when you are sure it won't be reversed, and a server-side redirect whenever possible. When URLs change, it advises keeping the redirects in place as long as possible, generally at least a year, and pointing each old URL directly to its final destination.

Setup examples

On Apache or LiteSpeed, in the .htaccess file, placed before the WordPress rules:

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

On Nginx, in the server block:

location = /old-post/ { return 301 https://www.example.com/new-post/; }

For WordPress

When you change the slug of a published post, WordPress remembers the old one and automatically issues a 301 redirect to the new permalink. This mechanism doesn't cover everything: a change of permalink structure, a page merge or a domain migration requires explicit rules, set on the server or with a redirection plugin that also logs 404s. After a migration, test a sample of old URLs and check that they lead to the right page in a single hop.

Common mistakes

  • Redirect chains: HTTP to HTTPS, then to www, then to the new URL. Each hop adds latency; Google's crawlers follow up to ten hops, but visitors pay for every round trip.
  • Sending everything to the home page: visitors don't find what they were looking for. Redirect to the equivalent page, or leave a real 404 if there isn't one.
  • A 302 left in place after a permanent move, often the default in some tools.
  • Redirects you didn't create: a hacked site can redirect some visitors to spam depending on where they come from. If visitors report strange redirects, read our article on SEO spam after a hack.

Don't confuse this with file aliases: changing the public URL of a theme's files isn't a page move and doesn't follow the same logic, as detailed in our article on masking WordPress and SEO.

Further reading

  • Article Hiding WordPress and changing addresses: the real effects on SEO
  • Article Hacked WordPress site and SEO: spam, deindexing and review

Sources

  1. Google Search Central: redirections et recherche Google (external link, opens in a new tab)
  2. Google Search Central: déplacer un site en modifiant les URL (external link, opens in a new tab)
  3. WordPress Developer Resources: wp_old_slug_redirect() (external link, opens in a new tab)

All definitions

Start free, go Pro when you’re ready

The free version already hides WordPress and moves the login page. Pro adds aliases, two-factor authentication and monitoring.