Start Exploring Keyword Ideas

Use Serpstat to find the best keywords for your website

10861 2
How-to 11 min read August 29, 2022

Configuring Redirects On A Website: How To Avoid Mistakes

Подробная инструкция по редиректам: когда и как их использовать
Фото Евгения Зайца, CEO Digital Yaponochka
Chief Marketing Officer at Serpstat
Both SEO specialists and developers have to deal with redirects. That being said, the former often don't understand how to set them up, and the latter — why they are needed.

This article will be useful for both, and hopefully, help them find common ground :)

What Is A Redirect?

A redirect is an automatic redirection of a user from one website page to another, carried out by the server. It can mean both a redirect within one domain or to another website.

Duplicate pages tend to worsen the website's rankings in search results, and
redirects help to deal with them.

They are also helpful when you need to create a new page to replace an existing one while maintaining search rankings and traffic.

There are 9 types of redirects, but only three of them are actively used in SEO: 301 Moved Permanently, 302 Moved Temporarily, and 307 Temporary Redirect. More on that later.

Why Do You Need Redirects?

Redirects are typically used for the following purposes:
To set up redirection of all visitors after changing the domain. This is important to as not to lose the entire audience of the website, which is used to finding it at a specific URL. Also, such a redirect allows you to save all the results of the website's optimization.
For SEO purposes, to "glue" domains, that is, to indicate to the search engine the preferred version of the website, for example, with www or without www. All visitors will be redirected to the option specified using the redirect, regardless of how they entered the website URL.
When changing the address format, you must also specify a redirect so as not to lose the existing traffic and optimization results. For example, when changing the address of "some-page.html" to "some-page" without an extension.
When switching to the secure HTTPS protocol.
When deleting a page from a website. To make sure the users don't get to a 404 page, they will immediately get redirected to a page with similar or the same content (if the URL is changed).

Most Common Redirect-Related Mistakes You Should Avoid:

  • multi-step redirects ("redirect chains") to pages where redirects are already configured. The redirect should lead to the target page without a subsequent redirection;
  • redirects to irrelevant pages. Redirects should lead to the content requested by a user. You must not configure redirects to a page that has significant differences from the original one, for example, to a completely different product in an online store;
  • redirects to deleted or inactive pages. You can only configure redirects to pages with a successful server response (200 OK) which indicates their correct operation;
  • redirects for doorways, i.e. websites that are optimized for a number of search queries and have no value for users. These websites are created specifically for redirecting users to other websites and their use contradicts Google's webmaster guidelines;
  • configuring a redirect instead of rel=canonical. If the page content is duplicated, for example, in print or mobile versions, it is preferable to specify a canonical address;
  • a very significant mistake is to configure a "302" redirect instead of a "301" redirect when changing a domain, deleting a page, or changing a URL.

Redirect Types

  • 300 Multiple Choices — multiple choices. There are several addresses to which a user is redirected depending on their choice or the browser settings:
Redirect 300 Multiple Choices
This redirect option is rarely used;

  • 301 Moved Permanently is a permanent redirect to a new address. This is the most popular redirect type removing the old address from the index, but retaining all its parameters and passing them to the new one. This option is also suitable for removing duplicates. You can apply it if you no longer need to use the current page or domain;
  • 302 Found is a temporary redirect to another address. A "302" redirect is leading you to a new page that is not indexed, and all results stay at the old URL. This type is not suitable if you change a domain;
  • 303 See Other is a redirect to a page that uses the GET method to display it. This redirect indicates that the document was found, but you need to use the GET request method to go to it even if the HEAD or POST were originally used. It is rarely used, for example, when one document was found as a result of a user search on a website. In this case, you can immediately redirect the visitor to it using a "303" redirect without showing the search results separately;
  • 304 Not Modified is a redirect indicating that the document has not been changed. This is a response the browser receives when it re-accesses a page that has not been modified. In this case, it must be downloaded from the browser cache;
  • 305 Use Proxy is a redirect to a page, performed through a proxy; its address is transmitted to the browser;
  • 306 Switch Proxy is not used at the moment. This redirect previously meant that future requests should occur through the transmitted proxy;
  • 307 Temporary Redirect is a redirect similar to a "302" redirect by its activity. It also temporarily replaces the address of the original version which is not removed from the index. Unlike a "302" redirect, it eliminates the ambiguity about whether to change the document request method.

How To Configure Redirects

Let's look at various ways of configuring the 301 redirects, as they're the most commonly used in SEO. All other redirect codes can be specified in the same way if necessary.

We will go over three main options:

  • using the .htaccess file in the root directory of the website;
  • setting up redirects on the page of a website using JS, PHP, or HTML code;
  • configuring redirects in the control panel of the hosting provider.

How To Specify 301 Redirects In .htaccess

A "301" redirect can be specified in the .htaccess file located in the root folder of the website. You can edit this file in the file manager of the hosting provider:
301 redirect via htaccess
A rule should be written at the beginning of the file that indicates to the server that there are redirects:
Setting redirects in htaccess file
A redirect of one page:
301 redirect pages in htaccess
A redirect of the whole website:
301 redirect site in htaccess
A redirect from WWW to a version without WWW, that is, a redirect specifying a mirror:
Specifying a mirror in htaccess
A redirect from HTTP to HTTPS:
Redirect from http to https in htaccess
Redirect from http to https in htaccess:
Redirect with a slash in htaccess

Configuring 301 Redirects Via Scripts

PHP Redirect

To redirect the entire website, the following code must be placed in the index.php file:
 header("HTTP/1.1 301 Moved Permanently"); 
When redirecting particular pages, you can use exactly the same construct by placing the code at the top of the document.

JS Redirect

You can use various JavaScript functions to configure redirects. Regardless of the implementation you choose, you must place the code inside the <script> </script> tags on the HTML page. A JS redirect requires that the source page from which the redirect is configured continues to exist. Here are the options of the redirect functions:

  • document.location="";
  • window.location.replace("");
  • window.location.reload("");
  • document.location.replace("");
  • location="";
  • a redirect after 10 seconds with a redirect message to a user:
function Redirect() 
    document.write("Our website has a new address, you will be redirected to it in 10 seconds"); 
    setTimeout('Redirect()', 10000);
HTML Redirect

The code is written in the <head> element; a redirect occurs in 5 seconds:
<meta http-equiv="refresh"="5;URL=" />
This option is not recommended by W3C which advises you to redirect users in other ways.

Configuring Redirects In The Hosting Control Panel

You can also configure redirects in the website's settings on the hosting. In this case, you can activate redirects to the secure HTTPS protocol and to the address format without WWW:
Setting redirects on hosting
When using such settings you need to consider whether there are such parameters in the CMS so as not to duplicate redirection rules or to establish conflicting redirects.


  • Using redirects allows you to redirect visitors when changing a domain, set redirects to similar products in the online store, and fight duplicate content;
  • Most often a "301" redirect is used for search engine optimization, as well as a "302" and a "307";
  • Technically you can implement redirects using the .htaccess file, or by placing the necessary HTML, JS, or PHP codes on the website pages.
To keep up with all the news from the Serpstat blog, subscribe to our newsletter. Also, follows us on LinkedIn, Facebook, and Twitter ;)
This article is a part of the Serpstat "Site Audit" tool
SEO Audit in Serpstat
Audit all the site or page in one click. A complete list of errors, sorted by severity, ways to resolve them and recommendations. Any frequency of verification and automatic email reports.
Run Site Audit

Speed up your search marketing growth with Serpstat!

Keyword and backlink opportunities, competitors' online strategy, daily rankings and SEO-related issues.

A pack of tools for reducing your time on SEO tasks.

Get free 7-day trial

Rate the article on a five-point scale

The article has already been rated by 1 people on average 5 out of 5
Found an error? Select it and press Ctrl + Enter to tell us

Discover More SEO Tools

Tools for Keywords

Keywords Research Tools – uncover untapped potential in your niche

Serpstat Features

SERP SEO Tool – the ultimate solution for website optimization

Keyword Difficulty Tool

Stay ahead of the competition and dominate your niche with our keywords difficulty tool

Check Page for SEO

On-page SEO checker – identify technical issues, optimize and drive more traffic to your website

Share this article with your friends

Are you sure?

Introducing Serpstat

Find out about the main features of the service in a convenient way for you!

Please send a request, and our specialist will offer you education options: a personal demonstration, a trial period, or materials for self-study and increasing expertise — everything for a comfortable start to work with Serpstat.




We are glad of your comment
I agree to Serpstat`s Privacy Policy.

Thank you, we have saved your new mailing settings.

Report a bug

Open support chat
mail pocket flipboard Messenger telegramm