Submit a request
16 minutes to read

Redirects: A How-to Guide

В интернете, как и в жизни, не так много постоянного — страницы меняют адреса, сайты переезжают на другие домены. Окончательно не запутаться во всемирной паутине помогают редиректы.

A server-side redirect is a type of instruction that informs the server that the requested page has been moved, so a different page hosted at a new address must be sent to the client (the web browser) instead. Redirect rules are set via your server settings, which is why it’s called a server-side redirect.

Thanks to a configured redirect, a user is able to view a different page than the one they requested, whether they clicked a link or typed the address themselves.

When to use redirects

  1. You changed your website’s domain name — let’s say it was a marketing move — and now you don’t want to lose the clients you had while telling search engines and other services that your website’s still there.
  2. You used to have two websites: Website A and Website B. After a while, you got rid of Website B, leaving only Website A functional. Now, you want all users to be taken to Website A when they send a request to Website B. A redirect would let all users and search engines know that Website B has taken the role of Website A.
  3. You deleted a certain page or section off your website, as it contained an obsolete product or service. In this case, it would make sense to redirect a user to a different page with up-to-date information that would fit their query.
  4. Technical redirects are also vital for eliminating duplicate content pages on your website, which is an essential part of search engine optimization (SEO). For instance, search engines see http://www.website.com,  https://www.website.com, and  http://website.com/index.html as separate resources. To counter that, they are merged, with one of the addresses becoming the canonical URL. To learn more about URL merging, see the rest of this document.

Redirection types

Redirection types are denoted with 3xx HTTP request response codes. Each code includes its own set of instructions. The following redirection types are especially useful when it comes to SEO:

  • 301 Moved Permanently
  • 302 Moved Temporarily
  • 302 Found
  • 303 See Other
  • 307 Temporary Redirect
  • 308 Permanent Redirect

Permanent redirects: codes 301 and 308. This type of server response means that the original page has been moved permanently. This prompts search engines to forget the old address and index the new one instead, setting it as the canonical URL for the website.

Temporary redirects: codes 302, 303, and 307. These codes mean that crawlers are aware of the new page, but this response will also continue indexing the old page, since the redirect is temporary. This often means that both pages are indexed in search results.

Temporary redirects are useful as a short-term solution for redirecting users to a page with a limited-time offer or sale. They can also be used to redirect the user from the main domain to a local domain depending on the user’s location. Otherwise, we recommend setting up a permanent redirect instead.

Codes 301 and 302 are the most common. Unlike codes 307 and 308, they allow you to change the HTTP request method from POST to GET.

Additional ways to initiate URL redirection without using server-side methods:

— Setting up a meta refresh or an HTTP refresh (set to 0 seconds for permanent redirects and more than 0 seconds for temporary redirects) in the head section of your HTML code or the page’s HTTP header.

— The “location” property in JavaScript.

— Crypto redirects, which are links located at the old address that lead to the new address and display a short redirect message.

However, keep in mind that all of the above methods should be used as a last resort for when you have no means to set up a proper server-side redirect 👍

Setting up a Code 301 redirect

The Code 301 redirect is your primary SEO tool. It’s used for all kinds of website or page-wide redirects except for temporary redirects (e.g., seasonal offer or sale, site maintenance, and so on).

The best way to set up a redirect is to add the necessary instructions to your server configuration and initiate a server-side redirect. Such redirects are the quickest and most easily indexed by search engines. Other redirect types we touched on above are initiated on the client side  (web browser): they take more time and may fail if the page has issues loading.

Apache servers are the most commonly used type of server. Their redirect instructions are stored in the .htaccess file. Although it’s a convenient method to configure your server, the file poses a security risk, as hackers can use it to set up malicious redirects if they gain access to your hosting service. Because of this, the .htaccess file can sometimes be disabled on Apache servers due to security concerns.

The other popular server type is an Nginx server. Unlike Apache, Nginx servers don’t have a dedicated file for redirect instructions. Instead, you set up redirects directly in your server configuration, just as you would on an Apache server with a disabled .htaccess file.

If you want to determine your website’s host server type, then you can check the response code on any of your pages using various dedicated tools, such as httpstatus.io. The returned header will include the server name.

If no server name is displayed, then this means the server has been hidden in some way (e.g., via a proxy server).

Whatever the case, we recommend contacting your webmaster or server administrator and asking them to set up redirects for you: a misconfigured redirect can introduce various issues, including restricted site access. You can read the information below to learn more.

SEO and Code 301 redirects

Core 301 redirects are an indispensable SEO tool. Its main advantages are link equity transferring, which Code 302 redirects can’t do, as well as telling crawlers when pages/domains have been merged.

Let’s say you have a popular page with a high ranking at /catalog/dresses/, which includes nested addresses for product pages at /catalog/dresses/item-123/. Some technical peculiarities of your engine force you to move the page to a different site section, which changes your URL to /catalog/women/dresses/. If you leave things as is, you will lose your rating and potential clients for some time, or may not even make it to top search results anymore due to your new address.

However, if you set up a Code 301 redirect from /catalog/dresses/ to /catalog/women/dresses/, then changing the URL won’t affect your ranking status. You should also set up Code 301 redirects for all nested pages for your products so that they take the user to the corresponding product pages in the new site section (/catalog/dresses/item-123/ turns into /catalog/women/dresses/item-123/). 

As you can see, the process is quite simple.

The main thing to keep in mind when merging pages is to not just merge addresses at random. Try to make the new URLs as similar to the old ones as possible in terms of page content.

Redirect Examples

In this section, we will break down the most common use cases for redirects.

Merging site mirrors

There are multiple ways to format links leading to the same website address, but they will be considered different websites by search engines. Such alternate links are called mirrors.

For instance, there are 4 main mirrors used by any website on the web:

  • http://site.com
  • http://www.site.com
  • https://site.com
  • https://www.site.com

To set one of those links as the canonical URL manually, you should set up a Code 301 redirect that takes the user from the http version to the https version—either the one that starts with the WWW or the one without it.

We recommend linking directly from your old URL to your new URL, without any in-between redirects.

Do this:
http://www.site.com →301 https://site.com 

Not this:
http://www.site.com →301 https://www.site.com →301 https://site.com

 

You can technically use redirect chains for URL requests, but it’s best to avoid them because they come with certain downsides, such as the following:

  • They can lead to endless recursive redirects
  • They drain the crawling budget, which makes it harder for a crawler to process the website
  • They can lead to longer load times
  • They can lead to partial loss of link equity
  • You can’t use more than five redirects in a chain, as a crawler might think that your website has been hacked and fail to scan it at all

Merging with a different domain

When you change your domain name or merge multiple websites, you must also set up a Code 301 redirect taking a user from the old domain to the new one.

Not only does this make it more convenient for users used to the old name, but it also lets you carry over link equity data from your old websites. This is especially important for cases when your domain name is brand new and hasn’t been used before; merging allows you to skip the growing pains and gain some link authority right out of the gate.

Just as with mirror redirects, try doing away with redirect chains. You should also ensure that  the content hosted at the new URLs is similar to the content from the old URLs so that a redirect makes sense. Sticking to these rules will facilitate a smooth transition and enable you to keep your new website’s visibility.

Deleting and moving website pages and sections

When you remove a page from your website’s layout, just turning it off in your admin dashboard is not a good course of action. Other existing pages may link to the page you removed, adding to your link equity. It may also be the case that the removed link has been indexed and became a large source of your website’s traffic, which will now be lost.

Before simply removing a page, think of a good redirect solution that would make sense to users. Usually this means redirecting users to a new page whose content is similar to that of the old one.

Let’s say you delete the page with the BAOMI dresses catalog at /catalog/dresses/BAOMI/. Doing that will mean you just lost all those potential products to sell. A sensible move here would be to set up a Code 301 redirect for the page and all its nested products that would lead the user one step above in the directory at /catalog/dresses/: the users won’t have access to the BAOMI dresses, but will still get a chance to take a look at some of your other products.

If there are no pages that are be similar enough to the old page to redirect to, you can still take the user to the homepage instead.

Technical page duplicates

CMS engines tend to create page duplicates, which are copies of the same page hosted at different URL addresses. In fact, it’s a very common occurrence.

As we already discussed, different URLs are different pages as far as search engines are concerned, which may lead to the same page being indexed many times. This, in turn, may deplete the crawling budget and negatively affect your site’s ranking, as the search engine may present different versions of the same page each time instead of only boosting one page.

Common cases of page duplicates:

  • Two versions of the same URL: one ending with a / and the other without the /. Example: /catalog/ and /catalog are different addresses.
  • Lowercase and uppercase. Example:  /catalog/Dresses/ and /catalog/dresses/.
  • The same character is repeated several times. Usually it’s a double slash (//), but there can be more, such as &&, ___, ??, and others. Example: catalog/Dresses////
  • GET parameters that don’t change page content. Example: /catalog/dresses/?date=2021-12-25/

As you manage your website, you may encounter unusual duplicate pages in the process, so make sure to learn the ins and outs of the engine you use.

The best course in such situations is to have only one active URL remaining, and setting a Code 301 redirect to all the other variants.

You should also make sure to configure your CMS plug-ins and modules so that your website’s code doesn’t produce duplicate pages on its own.

This might be hard to get around for GET parameters. For such cases, you may try using NOINDEX or the canonical metatag, which we will break down below.

Should I use a redirect or a canonical tag?

A common alternative to a 301 redirect used in SEO is a metatag with the rel=canonical attribute, although it works quite differently in practice.

The Code 301 redirect takes a user to a different URL altogether, without giving them the chance to learn the contents of the source URL. The search engine will obviously not rank the source URLs in this case as they get no traffic.

The canonical metatag simply says that the requested page is not canonical, while the canonical version is hosted at a different address.

A canonical page is the “main” version of the page among its duplicates as far as search engines are concerned.

A non-canonical page would be a page with the rel=”canonical” attribute and a link to the canonical version that follows the format of <link rel="canonical" href="canonical_page_URL"/>. 

Setting up canonical pages lets crawlers know which page they should index, although this makes no difference to the end user. However, the canonical tag may sometimes be ignored by the search engine. From what we can tell, Google can sometimes assign its own canonical status to pages, ignoring the tags set up by page owners. You can Search Console to learn if your page has a different canonical iteration from the one you host.

What do I choose?

— If you don’t want to take the user to the original URL (e.g. it no longer exists or was moved), use the Code 301 redirect.

— If you want to display the original URL (e.g. it shows filtering or paging results), use the canonical tag instead.

Both methods affect your site’s ranking, so make sure to use the right one for you.

Common mistakes when redirecting

You should always try to keep your redirecting instructions simple and clear to avoid possible complications. A wrong redirect can be even more harmful to your website than a duplicate or missing page.

Here are some common mistakes users are faced with when setting up redirects:

1. Redirect chains

Multiple redirects in a row create redirect chains that may pose problems such as those mentioned previously in this document.

2. A cyclic/loop redirect

Setting up a wrong redirect may result in a page redirecting the user to itself. This is called a cyclic redirect, as the server is given no instructions that would stop the process. Such pages can’t be properly displayed in-browser. Another common case is a redirect loop, which occurs when two different pages redirect the user to each other.

3. Any redirect that prevents the page from loading 

Any indexed page should return a Code 200. If a user is redirected to a Code 404 page (page not found) or a Code 500 page (internal server error), then they won’t be able to load the page they’re looking for. Only redirect users to indexed pages and tackle error codes manually.

4. Using redirects that don’t change internal URLs

If you move your website page or section without updating all the links that lead there, this will create unnecessary redirect chains. If you take care to keep your links up-to-date, then they will be scanned by crawlers much more quickly.

5. Using the wrong redirect type or using a temporary redirect instead of a permanent one

As we already covered, each redirect has its own code and purpose. Make sure to use the redirect type that best fits your goals. We recommend sticking to Code 301 and Code 302 redirects—you won’t need other options in most common cases.

6. Using the canonical tag instead of the Code 301 redirect and vice versa

Use the Code 301 redirect if you don’t want to display the original page to the end user or if it no longer exists. Use the canonical tag when you have to display the original page, even though it has an updated duplicate.

7. The robots.txt redirect

Some experts advise against redirecting the robots.txt file when switching domains. If you wish to merge website1.com with website2.com, leave the website1.com/robots.txt page up with a Code 200 and don’t use the Code 301 redirect on website2.com/robots.txt. This should make the merge go quicker.

However, this may not always be achievable in practice, and sometimes the robots file must also get redirected. This shouldn’t lead to any major issues, and the domains will eventually be fully merged regardless.

8. A redirect to a wrong page

Make sure to redirect users to relevant pages that are similar in content to the original ones. If you wish to merge two websites, make sure to read the Google recommendations on finding the best URLs for your redirects.

What’s next after I set up a redirect?

Let’s end this guide with the most interesting question: how long should you maintain a redirect?

If you configure your Apache server using an .htaccess file, each new instruction will add an extra line, which might unnecessarily bloat it after a few years, depending on how often you update your website. This will also make it more difficult to manage your redirect and may lead to unexpected cycle or loop redirects.

If you’re merging a different website with your own website, you should retain access to the source website, such as the original domain name and the hosting provider you’ve paid for. If the original website stops functioning, it will also bring down all the redirect links with it. However, this might force you to pay for a website you no longer maintain. So how long should you keep this up?

Google recommends doing this for at least one year, although even that might not always be enough 😅

Merged mirrors and technical duplicates should be maintained indefinitely. They should stay up after the initial setup.

You can probably delete redirects resulting from URL changes once the merge has been completed. However, make sure to check whether the old page is still being indexed before doing so.

You can check the indexing status of an old URL by entering its address into a search bar.

Google uses the site:{URL you wish to check} operator.

The address will be displayed only if it’s still being indexed.
 

You can also use Google Search Console to obtain detailed information about a specific page’s indexing status: simply type the URL into the search bar, but make sure you picked the right mirror.

If the redirects have been up for some time, they should stop getting indexed after a while. Make sure you update your website’s layout and ensure that no internal site links or external links lead to those pages any longer. If this is the case, you no longer need those redirects and can remove them.

How do I know if there are external links leading to an outdated redirect?

You can view this information via Search Console by opening a Links — Pages report, which includes a series of external site links. However, this report only displays the links indexed by the search engine, so it might miss some of them.

To make absolutely sure you didn’t miss any external links, you can also use a third-party crawler, such as the Ahrefs database (keep in mind that it’s a paid service, , but up to 100 backlinks you can use a free Backlink Checker). You can enter your page URL and check if it’s on there or if there are backlinks associated with it.

Conclusion: a redirect setup checklist

Here is a step-by-step breakdown on how to set up redirects:

✔️Make sure to use the correct redirect type. Always use the Code 301 redirect for SEO and maintaining your site’s rankings.

✔️Always redirect to pages with the same kind of content.

✔️ Ensure that the redirect target page is accessible, displays a Code 200, and loads with no issues.

✔️ Don’t use in-between addresses in your redirects and don’t set up redirect chains.

✔️ Make sure to fix all the internal links that take users to pages with a Code 301 redirect.

✔️ Confirm that your updated redirect instructions are not in conflict with earlier configuration and don’t cause redirect loops.

You can check your setup via a crawler by scanning the website and making sure the scan produced no issues.

Are you looking for efficient SEO?

Contact us for professional service and support
Interested in our services? Apply here
Apply
Нажмите и держите для максимального увеличения