zh
English Español Deutsch Français Italiano Português (Brasil) Русский 中文 日本語
前往博客
James Brockbank

The Ultimate Guide to Redirects: Everything You Need to Know about URL Redirection

98
Wow-Score
Wow-Score 表示博客帖子的参与度,是根据用户的主动阅读时间、滚动速度和文章长度之间的相关度计算得出。
James Brockbank
redirects guide

Redirects are used to forward both website visitors and search engines from one page to another when content is moved to a new location, a page is deleted from a site or even when changing the domain name. 

They are essential from both an SEO and user experience perspective, as neither visitors nor search engines want to encounter a page that no longer exists. 

But there are a number of different types of redirect, as well as multiple instances as to when each should and shouldn't be used. 

In this guide, I will walk you through everything you need to know about redirects, clear up confusion around some of the most commonly asked questions, and understand which type you need to use in different scenarios.

Specifically, I will cover:

What are Redirects and Why Are They So Important?

Quite simply, redirects are a way to forward traffic (or search engine bots) from one URL to another in instances when the original no longer exists.

If there is no redirect put in place, anyone who lands on a page that has been moved, or deleted, would see an error. 

404 page example

But why are redirects so important? 

Landing on an error page isn't a good experience for users who are expecting to see a live web page. This result can cause users to bounce or leave the site and means that converting this user into a customer or client, or even an email subscriber drops massively.

When we click a link, we expect to be taken to the relevant page, not served an error because it has been either moved or removed.

But that is when there is no redirect in place. 

Use a redirect to forward traffic to the new URL and you will have a happy visitor who, even though the URL is different, still ends up where they wanted to go. You have taken them straight from page A to page B.

When a page returns a 404 status code (or another not found error such a 410), search engines will pretty quickly drop it from the index — this means that it will no longer hold any rankings on the SERPs that it had.

Even if the page is only temporarily moved, you will still need to inform search engine bots.

And let's also not forget that any backlinks that point to a 404 page won't be counted by the algorithm and are, therefore, being wasted (yes, this does happen and an analysis of some of the world's most popular brand's websites revealed that there are literally thousands of great links going to waste because of this issue).

Forgetting to implement redirects really can result in lost search engine rankings, as well as disgruntled users. 

So whether you are redeveloping your website and your page's URL structure is changing, moving to a new domain, or even routinely cleaning up old content, you need to understand the importance of redirects when you should use them and which type to use. 

When to Use Redirects

You need to use redirects when:

  • You move the URL of a web page (from URL A to URL B).
  • You delete a page that receives traffic or has backlinks pointing to it.
  • You redevelop your website and the structure changes.
  • You move your website to a new domain name.
  • You merge two or more websites.
  • You migrate from HTTP to HTTPS.
  • You need to prevent duplicate content on trailing-slash URLs or non-www URLs.

Sometimes, you only need to redirect a single URL (or a series of single URLs) or directory on a site. Other times, you need to redirect an entire domain. But you need to understand that there are different types of redirects that you need to use depending on the situation and the end goal.

Understanding the Different Types of Redirects

The type of redirect that you implement very much depends on the reason why you need to do so, and whether the move is temporary or permanent.

Knowing the different redirect options means that you can use the right one in each scenario and prevent SEO or user experience issues from occurring. 

But please be aware that using the wrong type of redirect could result in a loss of search engine rankings in rare cases, as could not implementing redirects at all. If you have a complex situation and are unsure of which redirect type is the one that you need to use to prevent issues, or whether you need to put them in place at all, please seek advice from an experienced SEO.

HTTP Redirects

Perhaps the most commonly used type of redirects are HTTP redirects. 

Quite simply, as outlined by W3C, "A HTTP Redirect is a richer way to redirect because it gives the User-Agent more information than just the new address: the server also gives some information about the purpose and type of redirection, which allows the User-Agent to behave differently depending on the type of redirect." 

And it is this information about the purpose and type of the redirect that makes this type so common, meaning you can give different directions depending on your situation.

But what are the different types of HTTP redirects and which should you use when?

What type of redirect to use infographic

301 Redirects (Moved Permanently)

Using a 301 redirect indicates that the original URL's content has permanently moved to a new URL. 

Use this type of redirect when you need to forward users and search engines to a new page location and that the original URL won't be coming back. 

These are, by far, the most common and most talked about redirects and are one of the straightforward basics of SEO, given their ability to not only forward users but also pass on PageRank.

This means that, in most instances, these redirects pass on the authority that comes from backlinks, so long as the new page's topic closely matches the original.

You can learn more about this in this guide to 301 redirects.

302 Redirects (Found & Moved Temporarily)

A 302 redirect forwards a user from page A to page B but also signals that this move is only temporary and that the original URL will be reinstated. 

Historically, 302 redirects did not pass PageRank and, therefore, were known to cause SEO issues. 

It was confirmed in 2016 that this is no longer the case and that these do, in fact, pass link authority. Google's John Mueller said:

It's incorrect that 302 redirects wouldn't pass link PageRank. That's a myth.

— John Mueller, Google

This type of redirect should only be used in instances when the move is only temporary, let's say you're A/B testing a new page template or you want to redirect users to a different URL based upon their location or the device that they are using.

It is also believed by many SEOs that if 302 redirects are left in place for long periods of time, that Google begins to treat them like 301s. That said, the purpose and the way that these are handled is very different; even if PageRank does flow. 

When a 301 redirect is in place, URLs will be consolidated in Google's index. However, with 302s, the original remains indexed and will continue to rank. Be sure to think carefully about whether a move is permanent or not before implementing 301s or 302s. 

These are, by far, the two most common types of redirect, but there are other variants that you may come across occasionally.

303 Redirects (See Other)

While rarely talked about in the context of SEO (for the simple reason that this type of redirect has nothing to do with it ... at all), 303 redirects can be used to indicate that the redirects don't link to the newly uploaded resources, but to another page (such as a confirmation page or an upload progress page). 

These can be used to prevent a form's contents being resubmitted when a user hits their browser's back button, as an example.

307 Redirects (Moved Temporarily)

Very similar to a 302, a 307 redirect is it's HTTP 1.1 equivalent and can be used when a URL needs to be temporarily redirected. 

The usage scenarios are, for the most part, the same as for 302 redirects. However, it is believed that 307s do not pass PageRank, and, for this reason, these should be avoided if at all possible and 302s used. 

308 Redirects (Moved Permanently)

As you have perhaps figured out, a 308 redirect is the permanent equivalent of a 307 and, for the same reasons, should be avoided where possible from an SEO perspective.

Stick to using 301s whenever you can.

JavaScript Redirects

You can use JavaScript to redirect users and search engines from one page to another. For a long time, Google could not properly recognize these in the same way as server-side HTML redirects. 

However, John Mueller confirmed in 2019 that, "We support JavaScript redirects of different types and follow them similar to how we’d follow server-side redirects." 

Google has gotten pretty good at rendering JavaScript and, therefore, the concerns over this type of redirects should no longer be the same as they once were, and evidence exists that these now pass PageRank.

Meta Refresh Redirects

Unlike HTML redirects, which are handled server-side, it is also possible to redirect one page to another client-side (in the browser).

This is known as a meta refresh redirect, where a meta tag in a page's <head></head> section instructs the browser to go to another page after a specified length of time. 

You will often find that this type of redirect is used alongside a countdown that informs the user that they will be redirected in a number of seconds. 

Google has confirmed that these are handled just like any other redirect. However, issues still exist in that these offer a poor user experience due to the time taken to process and the fact that the original page is kept in the browser's history. 

For these to be treated in the same way as a 301 redirect, the refresh time should be either 0 or 1 second.

Common Ways to Implement Redirects

The way that redirects are implemented differs depending on your web server configuration and CMS. As a general rule, here are some of the most common ways that you can implement redirects:

  • By editing your site's .htaccess file (when hosted on an Apache server).
  • By adding a server block to your nginx.conf file (when your server runs Nginx).
  • By importing the mod_redirect module and using url.redirect (when on a Lighttpd server).
  • Using the 'Easy Redirects Manager' plugin if you use WordPress.
  • Using the built-in URL rewrites module if you run Magento.
  • Using the built-in URL redirects function if you use Shopify.

As referenced above, meta refresh redirects and JavaScript redirects (as well as PHP redirects) are other alternatives to redirect users, but they do not come recommended as an SEO-friendly solution.

A Simple Guide to Getting Redirects Right and Avoiding Common Issues

While understanding the importance of redirects is pretty straightforward, incorrectly implementing them can result in issues that relate both to SEO and user experience. There are common problems that occur time after time that you need to be aware of and work to prevent on your own or your client's sites.

Always Redirect to Close Match Content

When redirecting one page to another, you need to make sure that the new page's content is a very close match to the old page's; otherwise, this is likely to be handled as a soft 404.

If a user clicks a link to visit a page that sells red dresses, they want to browse these products. They wouldn't want to (or expect to) be redirected to a page that sold "jeans." If the store no longer stocked red dresses, it would be acceptable to redirect to a top-level dresses category, as an example.

Avoid Redirect Chains and Loops

Redirect chains and loops are two common problems that occur with redirects. In fact, this study into internal linking mistakes highlighted that 8.3% of websites suffer from these issues.

Chart showing redirect chain and loop mistakes

Quite simply, a redirect chain is when more than one redirect exists between the original URL and the final URL and often happens as a result of website migrations.

Let's say that your about page used to sit on /about-the-company/ (A) and then moved to /about-us/ (B). You have now gone and launched a new site and changed the URL of this page to /about/ (C).

If A redirects to B, then B redirects to C, then you have created a redirect chain.

These are unnecessary and should be avoided. If you have any that currently exist, they should be updated (in this example, you would redirect straight from A to C, even if you also needed to redirect from B to C.)

A redirect loop is where the destination cannot be reached. Imagine you want to redirect from A to C, but C also redirect to A. Again, this should be avoided for the simple reason that the redirect is broken and won't actually forward visitors or search engines to the destination.

You can use the SEMrush site audit tool to check for and gain an insight into issues caused by both redirect chain and redirect loops.

redirect chains and loops

Avoid Internal Redirects

When you change the URL of a page, it is sometimes easy to forget to go back and update internal links to point to this new location, especially when you have put redirects in place.

These redirects are unnecessary, given that you have full control to repoint internal links. 

Of course, it is important that you do have these URLs, just make sure you go into your site's content and update the destination of internal links to avoid redirecting users and search engines in cases when it is not needed.

Don't Use 302 Redirects Unless the Move is Temporary

We have already looked at the way search engines handle 301 and 302 redirects differently, but you do need to carefully consider which type is right for you to use.

This generally means making sure you don't use 302 redirects unless the move will be temporary and won't exist long-term.

Let's not forget that 302 redirects don't drop out of Google's index, as one example.

In fact, the SEMrush study suggested that 32.2% of websites are incorrectly using temporary redirects, with a typical one having 1.42% of its pages using this type of redirect. 

A chart showing temporary redirect issues

Redirecting to Prevent Duplicate URLs

It is not uncommon to find that a site exists on duplicate URLs (non-www and www, HTTP and HTTPS, etc.), but this can easily be resolved by 301 redirecting all variants to a single canonical URL.

Be sure to use redirects to prevent duplicate URLs that could exist between:

  • Non-www and www
  • HTTP and HTTPS
  • Trailing-slash (/) and non-trailing-slash URLs
  • Capitalized and lower-case URLs

Redirecting to Fix Linked 404 Errors and Regain Lost Link Authority

Did you know that Google ignores backlinks that point to a 404 page?

You can use the SEMrush backlink analytics tool to uncover 404 pages that have links pointing to them. 

Just head over to the Indexed Pages tab in your completed report and tick the Target URL error box. You will be served a list of 404'd URLs that have links pointing to them that you can now go away and 301 redirect to a close match page to reclaim lost link authority.

Linked 404 data from SEMrush

Commonly Asked Redirect Questions

We have looked at what redirects are, the different types, and some ways to avoid common issues, but let's also answer some of the most commonly asked questions on the topic.

Do Redirects Pass PageRank?

Yes.

If there is a close match between the content on Page A and Page B, PageRank will be passed along redirects, even in instances when a 302 redirect is used. When there is no match between the content, the redirect will be classed as a soft 404 and would not bass PageRank.

However, 301 redirects should be used in preference when you wish to pass link authority to a new URL.

Are Redirects Bad for SEO?

No, redirects are not bad for SEO.

In fact, in many ways, they are the exact opposite; as long as they are used in the right instances.

Think about it this way — if you don't use redirects but move or remove a URL, neither users nor search engines will be forwarded to the new page when they land on the old URL. This can cause keyword rankings to drop and users to bounce from the site. 

When redirects are used, they help to prevent these issues.

That said, redirects should not be overused and issues such as redirect chains and loops should be avoided whenever possible. 

How Long Should You Keep Redirects in Place For?

This is a frequently debated topic amongst SEOs, but it has been confirmed by John Mueller from Google that, "After a few years the old URLs are often no longer accessed & you can drop those redirects."

Based on John's guidance and other experiences, we would recommend that you keep redirects in place for at least three years. However, in cases where the number is not significant, there is no harm in this being longer. 

How Do I Test Redirects?

Sometimes, you will know that a redirect is in place because you are forwarded to a different location when visiting the URL. But how do you test redirects to check whether they are working properly or are 301s or 302s?

You can see both temporary and permanent redirects in your site audit report and Google Search Console.

If you want to test a specific URL, you can use a tool such as httpstatus.io.

To Recap

Redirects are a vital part of SEO, but their use goes way beyond just this. 

You need to use redirects whenever you change the location of a web page. If you don't, users and search engines will not be forwarded to the new one, and this in itself can cause SEO issues as well as causing customers to drop off.

Take the time to understand how redirects work, learn the different types you can use, and spend some time testing them and you will be ready to implement them and prevent the common issues that are often seen.


Remember, check out the SEMrush site audit tool to gain insights into issues your website may have due to a redirect chain and redirect loops.

James Brockbank
传奇

难以企及!

James is Managing Director of award-winning digital PR and SEO agency, Digitaloft, and has been involved in search marketing since the mid-2000s. He's a regular writer on topics including link building, content marketing and eCommerce, having previously contributed to the likes of Search Engine Journal.
发送反馈
您的反馈必须包含至少 3 个单词(10 个字符)。

我们只会使用您的电子邮件,以回答您的反馈。 隐私政策

感谢您的反馈!