Redirects: Which Ones to Use and How to Set Them up

Redirects: Which Ones to Use and How to Set Them upHow to

In this post we will talk about the most common redirects and issues they may cause with entertainment allusions ;) Also, I’ll explain how to prepare a list of redirects for moving to another website engine (CMS). Sounds interesting? Let’s get this sorted out.

1. What Is a Redirect?

Redirect leads both users and search engines to another URL instead of requested one. So you have to know what you need them for, where do they lead and which type of them do you have to set up.

2. Types of Redirects and What They Are Needed for

You should clearly understand the purpose of each redirect on your website and choose the most appropriate one. Browsers and search engine robots determine redirect type according to the HTTP status code. Redirects have different HTTP statuses (301, 302, 303, 307) and in this post we will talk about them in details.

Moreover, redirects are sorted by implementation. You can configure redirection through the .htaccess or nginx.config file and using PHP (they are implemented on the server side); HTML or JavaScript (on the browser side). In our post we dwell on the server redirects configured in the .htaccess file for websites on Apache server and glance at Meta Refresh executed at the web page level.

To make changes in the .htaccess file you should access the file via FTP client, for example, FileZilla. You can see a detailed example of redirect implementation in the .htaccess file in our post about switching to HTTPS.

2.1. 301 Redirect Moved Permanently

301 redirect is a permanent redirect usually used for saving link juice when the web page has been moved to a new address and the old URL is out of date. As Matt Cutts once said, pages with a 301 redirect lose as much link juice as a simple link (almost 10%). However, it’s the most reliable way of redirection if you crave to save almost all link equity on your web page.

301 Redirect
Like any serious relationships, 301 is for a long-long time (maybe even a whole life)

Cases of Using 301 Redirect

We have gathered common cases of using 301 redirect and code examples for Apache server.

WWW Redirects

This is how to set up redirect from domain with www to the domain without www:

RewriteCond %{HTTP_HOST} ^www\.bacon\.com$ [NC] RewriteRule ^(.*)$$1 [R=301,L]

And this is how you redirect URL without www to the URL with www:

RewriteCond %{HTTP_HOST} ^bacon\.com$ [NC] RewriteRule ^(.*)$$1 [R=301,L]

Сhanging File Extension

If you have moved to another platform or CMS and in this process only URL extensions were changed, you should use the following redirect.

RedirectMatch 301 (.*)\.php$$1.html

Redirection from Different Domains and Subdomains

If you have bought several domains in different domain zones or have been redesigning a new website on a subdomain, you should redirect all additional domains or subdomains to the primary domain:

RewriteCond%{HTTP_HOST}!^www\.site\.com.(.*)$ [NC] RewriteRule ^(.*)$ %1/$1 [R=301,L]

Now all domains such as,, will be redirected to

Slashes at the End of the URL

You should remember that search engines consider URLs with and without slash ( and as two different URLs. Decide which one is more appropriate for your website and set up the following redirects.

To remove a slash at the end of URL:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301]

To add a slash at the end of URL:

RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

Switching from HTTP to HTTPS

You need to set a redirect instruction for the 301 redirect to HTTPS version of the website. If you have WordPress CMS with hosting controlling by cPanel, you can read a detailed guide on moving to HTTPS.

Fixing broken links

If you’ve permanently deleted one of your pages and created a new one instead, set 301 redirect to the main or new page and remove all links within your website leading to the nonexistent one.

RewriteRule ^old/URL/path$ [L,R=301]

And make sure to check out our detailed post about broken links.

2.2. 302 Found (HTTP 1.1) / Moved Temporarily (HTTP 1.0)

302 redirect is a temporary one. So it can be used while testing new pages or website redesigning. This type of redirects is not appreciated in SEO because it’s generally believed among SEO specialists that it loses PageRank. But Gary Illyes is certain that it doesn’t. To verify this statement, Dan Kern conducted an experiment and found out that 302 redirect indeed passes PR.

302 Redirect
302: when relations are just temporary but mean a lot

There are different response statuses for two versions of 302 redirect:

  • HTTP 1.0: 302 response status code is ‘Moved Temporarily’. It means that current document is temporarily moved to a different URL.
  • HTTP 1.1: 302 response status code ‘Found’ – current document was found with another address.

You can write such directive in .htaccess file to set it:

Redirect 302 /old.html http://localhost/new.html

2.3. 307 Moved Temporarily (HTTP 1.1 Only) and 303 See Other

These redirects were created to eliminate ambiguity with 302 redirect.

You can implement ‘307 Moved Temporarily’ when the content is moved only temporarily (for example, during redesigning). It lets search engines know that your server is compatible with HTTP 1.1.

Moreover, clients should not follow the redirect automatically for POST/PUT/DELETE requests. Caching should be performed only if there are Cache-Control or Expires headers in the server response.

303-307 Redirects
No serious intentions, you know

Along with 307 redirect, 303 redirect was released. It’s used quite rarely. For example, when the user is searching for the one type of document on the website and another type was found. In this case, instead of showing this document in search results, you can use 303 redirect to point to the user the document found in the Location header. Then the user will immediately see what he is searching for without viewing search results. Users for this resource should follow the redirect for POST/PUT/DELETE requests, but use GET for the follow-up request. This redirection is not allowed for caching.

2.4. Meta Refresh

You can also set redirects using Meta Refresh or JavaScript. They are executed at the web page level (not server level). This SEO tactic is not recommended because of poor usability, similarity to the common spam technique and loss of link juice.

Meta Refresh
Such crap can happen with everyone, especially if you party a lot

According to W3C: 'In HTML and XHTML, one can use the meta element with the value of the http-equiv attribute set to "Refresh" and the value of the content attribute set to "0" (meaning zero seconds), followed by the URI that the browser should request. It is important that the time-out is set to zero, to avoid that content is displayed before the new page is loaded. The page containing the redirect code should only contain information related to the redirect.'

<html xmlns="http://www.bacon/tasty/xhtml"> <head> <title>Best Sandwiches</title> <meta http-equiv="refresh" content="0;URL=''" /> </head> <body> <p>This page has moved to a <a href=""></a>.</p> </body> </html>
Example of Meta Refresh

3. How to Prepare the List of Redirects for Moving to Another Website Engine (CMS)

When you are redesigning your website or moving to another CMS, you should prepare the list of redirects. Why? Because if you don’t want to commit your website’s suicide, make sure that your content is delivered to your user and link juice is saved.

How to Prepare the list of Redirects with Netpeak Spider
Just like after divorce, you have to pack all your stuff and move forward

In such cases as moving to another CMS, URL structure is usually different from the previous website version. Of course, we need to save all URLs in search and preserve link juice as much as possible. And 301 redirect can help in this situation. But what to do if there are dozens of thousands of pages on your website? It is usually difficult to write universal redirection rules. Moreover, issues connected with redirections can be very harmful to your website.

To carry out this time-consuming task you can use Netpeak Spider and gather all URLs from your website:

  1. Choose crawling mode ‘Entire Website’ (in ‘General’ tab of ‘Crawling Settings’) and select ‘Crawl All Subdomains’.
  2. Select all content types and URLs from the tag.
  3. Parameters can be left by default.
  4. Untick the following indexation instructions in ‘Advanced’ tab. Now you won’t miss any web page, if it has URL ;)

After that start crawling. As soon as it’s finished, export received data, move URL column to a new sheet, sort it alphabetically and fill the second column with new addresses.

Just to be on the safe side, you must set redirects on web pages with backlinks. You can use such tools as Majestic and Ahrefs to find them.

4. Redirect Issues

Here is a list of the common issues connected with redirects. Try to avoid them like a plague.

  • Redirect to 4xx Error Page. Don’t forget that the main purpose of redirects is to lead users and search engines to the working URL despite all changes at the website.
  • Redirect to irrelevant pages/content. Don’t upset your users and set up redirects to the web page with the content they are looking for.
  • Endless redirect. It indicates all pages redirecting to themselves and thereby generating infinite redirect loop. It can occur because of the mistake in htaccess file.
  • Any multi-step redirects. Try not to use them because they slow down loading speed and make your pages lose link juice.
  • Redirect blocked by Robots.txt. In such case, URL you are redirecting to will be missed by search engines.
  • Redirect with bad URL format in HTTP response headers.

After implementing redirects, check your website and see results. Netpeak Spider can help you identify all issues connected with them on your website. Make sure to choose ‘Redirects’, ‘Redirect Target URL’ and ‘Status Code’ in ‘Parameters’ tab in ‘Crawling Settings’ before crawling. And there is a little feature hiding here. Only status codes that are present on your website will be displayed, nothing redundant ;)

And FYI, our crawler indicates error ‘Max Redirections’ (all URLs redirecting more than 4 times) but you can change the maximum number of redirects Netpeak Spider has to follow in the 'Restriction' tab of ‘Crawling Settings’.

5. In a Nutshell

  • Redirects lead users and search engines to another URL instead of requested one. The most common types are 301, 302, 303, 307 and Meta Refresh.
  • They are used for different purposes:
    • 301 – for permanently moved content or web page, to put together domains with and without www, slashes at the end of the URL, switching to HTTPS and fixing broken links.
    • 302 and 307 are used for temporary moving.
    • 303 See Other is a special redirect indicating that the requested document was found. But you should use GET method, regardless of the method the original document was requested with.
    • And finally Meta Refresh. It is not recommended for SEO because it doesn’t pass link juice and is widely used by spammers.
  • In case if you need to prepare list of redirects for moving to another CMS Netpeak Spider can gather all internal redirects of your website.
  • And of course after all implementations you should re-check redirects on your website. With Netpeak Spider you can find such issues connected with them as redirect to 4xx error page, endless redirect, redirect blocked by Robots.txt and redirect with bad URL format.

We hope this information will be helpful for you, so if you have any questions or want to share your own experience, don’t hesitate to drop us a line in comments below ;)