Redirects

301 redirects: how to set one up and when to use it

7 min readUpdated

A 301 redirect is the HTTP status 301 Moved Permanently: a page now lives at a new address for good. Google shows the new address in results and, in its own words, "301 and other permanent redirects don't cause a loss in PageRank." Among the redirect codes, it is the answer for a page that has moved.

What the code means

The HTTP specification, RFC 9110, defines it: the 301 status "indicates that the target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs."

"Permanent" is the operative word. A browser may remember the answer and skip the old address next time, and anything that stores links is invited to update them. That makes a 301 cheap to follow and expensive to take back, which the overview of redirects covers in more detail. The temporary counterpart, for moves you expect to undo, is the 302 redirect.

What Google does with a 301

Google follows a 301 and treats the target as the address to show. Its documentation on redirects, last updated on and checked on , sums up permanent redirects as "Show the new redirect target in search results," and says the indexing pipeline uses them "as a signal that the redirect target should be canonical."

Its guide to site moves, last updated on , adds the three points people most often ask about:

  • Value: "301 and other permanent redirects don't cause a loss in PageRank."
  • Choice of code: "we recommend that you use HTTP permanent redirects if possible, such as 301 and 308."
  • Duration: "Keep the redirects for as long as possible, generally at least 1 year."

The redirects documentation adds that after a move to a new domain Google may "continue to occasionally show the old URLs in the results, even though the new URLs are already indexed." That is expected, and it fades without any action on your part.

When to use a 301

Use a 301 whenever the old address should stop representing the page. Typical cases on example.com:

  • A renamed page: /atlas-40-backpack/ becomes /atlas-40/.
  • A merged page: two thin guides become one, and both old addresses point to it.
  • A new domain: every address on the old domain points to its equivalent on the new one.
  • A move to HTTPS: every http:// address points to its https:// copy, as covered under HTTP to HTTPS.
  • A removed page with a successor: the old product points to the model that replaced it.

The last case comes with a condition: the target must actually replace the old page. Sending every retired address to the home page is not a move, and readers and search engines both treat it as one destination standing in for many unrelated ones.

How to set up a 301 redirect

Where you set a 301 depends on what answers the request, and in every place the same rule applies: name the status. The most common ways of writing a redirect send a temporary 302 unless told otherwise, which is the single most frequent reason a permanent move is read as temporary.

  • On Apache

    Rules go in the server configuration or in a site's .htaccess file. The Redirect directive needs permanent or 301 before the path, and RewriteRule needs the flag [R=301]; both default to 302 without it. The .htaccess redirect page quotes Apache's own examples.

  • On nginx

    Rules go in the server configuration, using the return or rewrite directive. Both send a 302 unless a permanent code or the permanent flag is given; nginx redirects quotes the syntax from nginx's documentation.

  • In WordPress

    A redirect plugin, a server rule or the wp_redirect() function; the function defaults to 302, so a permanent move passes 301 as its second argument. WordPress redirects compares the three paths.

  • On a hosted platform

    Site builders and online shops usually offer a redirects screen in their settings, and the redirect is issued by the platform. Look for whether you can choose the status, and check the response after saving.

Whichever route you take, test one address before applying a rule to many.

Moving many addresses

A larger move starts with a list, not with rules. Google's site-move guide says to "Create a mapping of old to new URLs" before redirecting, and the reasoning holds for any size of change.

Export every old address while it still answers, from your sitemap, your analytics and your server logs. Decide where each one goes, one to one, keeping the closest equivalent page. Then express the mapping as rules, using patterns only where a whole group of addresses changes the same way; for a change of domain, Google mentions "a wildcard server-side redirect" as the usual tool.

Keep the mapping after the move. It is the record you will need when a rule has to be rebuilt on a new server, and the only way to check, months later, that every old address still lands where it should.

Mistakes that undo a 301

Most problems with 301 redirects come from the path, not the code.

  • Chains. A redirect added on top of an older one makes two hops where one would do; point every old address straight at the final destination. Redirect chains covers finding and collapsing them.
  • The wrong code. A move made with a 302, often by a default, keeps the old address in results.
  • Everything to the home page. A one-to-many collapse loses the match between old and new content.
  • Signals that disagree. Internal links, the sitemap and canonical tags should all name the new address; a canonical tag pointing back at the old one contradicts the redirect.
  • Removing the redirect too soon. Google advises keeping it "generally at least 1 year"; links from other sites can keep sending people for much longer.

301 or 308

Both are permanent, and Google names both as its recommended codes. The difference is the request: a 301 lets a client turn a submitted form into a plain page load, while a 308 requires the request to be repeated as sent. For ordinary pages either works; for addresses that receive forms or API calls, use 308. The pair is covered under 307 and 308 redirects.

Checking the move

Check the response, not the configuration. Request each old address and read the status line and the Location header: a moved page should answer with 301 or 308 and the final address, in one hop. Check a sample that includes old addresses with query strings and with and without a trailing slash. How a trace reads each hop and its status is covered under redirect tracing.

FAQ

Are 301 redirects bad for SEO?

No. Google's site-move guide says that "301 and other permanent redirects don't cause a loss in PageRank," and it recommends permanent redirects for moves. Problems come from how they are used: chains of several hops, temporary codes where a permanent one was meant, or many unrelated pages sent to the home page.

How long should a 301 redirect stay in place?

Google advises keeping redirects "for as long as possible, generally at least 1 year." Links from other sites, bookmarks and old documents can keep sending people to the old address for years, so there is rarely a reason to remove a working redirect at all.

Does a 301 redirect pass PageRank?

Google states that permanent redirects, including 301, do not cause a loss in PageRank. It also uses a 301 as a signal that the target should be the canonical address, so the new page takes the old one's place in results. Keep other signals, such as internal links and canonical tags, consistent with the move.

Should I use a 301 or a 308?

Both are permanent and both are recommended by Google. A 308 also requires the request method to be kept, so a submitted form arrives as a form, not as a plain page load. For ordinary pages either code works; for addresses that receive forms or API calls, choose 308.