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
| Code | Type | Effect for Google |
|---|---|---|
| 301, 308 | Permanent | Strong signal that the target should become the canonical URL |
| 302, 303, 307 | Temporary | The old URL may stay in the results |
| Instant meta refresh | Treated as permanent | Only for cases where the server can't redirect |
| JavaScript redirect | Last resort | Only 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.