Redirect 301: The mega guide

Learn how to implement all types of permanent redirects by using our easy-to-use 301 redirect mega guide.

Published by 

Alexis Pratsides


Case study featured image for
  1. 1 – What is a 301 redirect?
  2. 2 – What is a 301 redirect for?
    1. a. Full domain redirects
    2. b. Unify websites with redirects
    3. c. Avoid keyword cannibalisations with redirects
    4. d. URL redirections to remove
  3. 3 – How do I create a 301 redirect?
    1. a. 301 Redirect .htaccess
    2. b. 301 redirect php
    3. c. 301 redirect html
    4. d. 301 redirect JavaScript
  4. 4 – What are 301 redirect chains?
  5. 5 – Most common 301 redirects
    1. a. Redirect from non-WWW to WWW or vice versa
    2. b. Redirect from 5.2 Redirect from http to https or vice versa
    3. c. Redirect without www and http to www and https
    4. d. Redirect Slash to the end of the URLs
    5. e. Redirect a full domain to a new domain
    6. f. Redirect a full domain to the homepage of another domain
    7. g. Redirect the homepage to another URL
    8. h. Redirect a full directory
    9. i. Redirect a specific page
  6. 6 – How do I check a 301 redirect?
  7. 7 – Conclusions about redirections

What is a 301 redirect?

To start talking about 301 redirects, we must first describe what redirects are exactly. In short, a redirect means to take visitors from one web page to another (either from the same website or from another second website) automatically.

There are several types of redirects but in short, we could summarise by saying there are “temporary” redirects and “permanent” redirects.

A 301 redirect is a permanent redirect from one page to another, so when we use this type of redirection, we are telling search engines that this change from one URL to another is definitive.

What is a 301 redirect for?

As mentioned, a 301 redirect tells search engines we’ve made a definitive change from one URL to another.

What’s next? Google will interpret that URL1 (the one we want to redirect) will now become URL2 and therefore Google will pass the link equity of URL1 to URL2 and count the links as of this second URL.

As an SEO agency, we use permanent redirects when dealing with complex website migrations or any change in the website architecture in order to pass the link equity from the old URL.

Full domain redirects

Not all redirects will have the same impact. If you redirect a cosmetic website which is currently ranking well for cosmetic queries and decide to redirect the whole domain to a car-rental website, it doesn’t look natural. Remember to redirect only relevant websites i.e. industry-related sites.

Using 301’s to unify websites

Let’s say we have three luxury car websites; Porsche, Ferrari and Lamborghini, we can unify the 3 of them into a single luxury car website. If done well, we will be able to unify the three smaller websites into a much larger one. Obviously if not implemented correctly, we could potentially lose the SEO value of the three smaller websites.

Avoid keyword cannibalisations with redirects

Another great use of redirections is to avoid keyword cannibalisation. If we have a URL1 ranking by a certain keyword and a URL2 also ranking by it … we can redirect one of these URLs to the other one so that we only have a single result and do not lose the strength of both URLs.

URL redirections to remove

Another good use of 301 redirects is when for example an e-commerce website wants to eliminate a product because they aren’t going to sell it anymore and that URL is ranking well or has good incoming links (also known as backlinks).

If we remove that URL we will lose its ‘Page Authority’. However, if we have another related product and we do a 301 redirect to it, we will take advantage of both the strength and the links of the original URL.

How to write a 301 redirect

If you are at this stage you will already have a clear understanding about what page you want to redirect and where you want it to go. But how do you implement the redirect?

Below we explain the different options with their pros and cons.


This type of redirect is done by modifying the .htaccess file. The .htaccess file is a configuration file read by the server that allows you to do many things like rewrite URL’s.

The great thing about this file is that we can perform redirect patterns and redirect complete directories with only one command. That is, it makes our work much easier if we know how to use .htaccess redirects correctly.

We will explain later how to perform some of the most common redirects using .htaccess.


This type of redirection is done directly at PHP programming level and therefore you have to place the code inside the specific URL that we want to redirect.

See an example below:

header("Status: 301 Moved Permanently");

The downside of this type of redirect is that if we use a CMS platform like WordPress, it will be fairly complicated to implement as we will need to edit the site files which could introduce problems in future if we forget where exactly we have placed that redirection code.


In html we can use ‘meta refresh’ to create redirects. After a few seconds, the page is “updated” and redirected to a second URL.

meta http-equiv="refresh" content=”0: url=”>

This type of redirect is not technically a 301 and therefore does not pass link authority.


In JavaScript we can also create a redirection for example using this code:

window.location.replace ('');

This is also not technically a proper 301 redirect and therefore will not pass authority. The reason for this is the 301 HTTP status code is created at the server side and Javascript is executed at the browser level. When the content is loaded to the browser, Javascript will take effect and redirect users to a new content but the page itself will remain status code 200, not 301.

The most common way of implementing 301 redirects is using .htaccess. You need to have access to your server and apache configuration file. If you don’t have access you’ll have to reach out to your hosting company and request it.

What are 301 redirect chains

It is a series of consecutive redirects that go from one URL after another such as URL1 -> URL2 -> URL3 -> URL4 and so on.

301 redirect chains

To 301 redirect pages using the .htaccess file, you will add a line to the file that tells the server what to do. What are the most common 301 redirects? We will show you a few of the most commonly used 301’s using the .htaccess file.

301 Redirect from non-WWW to WWW or vice versa

www to non www 301 redirect

Search engines consider and different websites.

Ideally you should pick your preferred URL and implement a 301 redirect on the other. It would make sense to pick the URL with the stronger back link profile. You can check which domain has the stronger backlink profile by using any SEO tool, for example, Moz, SEMrush, Ahrefs or something similar.

Having this kind of redirect in place is very important to avoid duplicate content and allows you to effectively consolidate all of your link popularity to a single URL. This consolidation will serve to increase your website’s chances of obtaining and maintaining top rankings.

Should you want to redirect from to you’d need to paste the following code into the .htaccess file (remembering to change to your website name):

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

Should you want to redirect from to you’d need to use the following code:

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

Redirect from http to https or vice versa

301 redirect http to https

This redirect is very helpful in the event that you don’t want to or can’t use a WordPress plugin:

If we want to redirect from to

RewriteCond %{HTTPS} off
RewriteRule (.*)$1 [R=301,L,QSA]

If we want to redirect from to

RewriteCond %{HTTPS} on
RewriteRule (.*)$1 [R=301,L,QSA]

Redirect without www and http to www and https

301 redirect http and non www to https and www

If we want to redirect from to (2 things at the same time – the http to https and addition of www) we can do it in 2 steps with 2 codes:

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^
RewriteRule ^{REQUEST_URI} [L,R=301]

Redirect slash to the end of the URLs

301 Redirect slash at the end of a url

Sometimes websites are able to load with the slash ‘/’ at the end or without it, as minor as this seems, it can generate duplicate URLs. While Google doesn’t consider these URLs as duplicate content its best practice to have them redirect.

The code to redirect to is:

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

The code to redirect is:

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

Redirect a full domain to a new domain

301nRedirect a full domain to a new domain

If you want to redirect a complete domain with all its architecture like to

Redirect 301 /

NOTE: Don’t forget to add ‘/’ at the end of if you want to redirect all the architecture of internal URLs correctly.

Redirect a full domain to the homepage of another domain

In some cases, people will redirect an entire domain’s URLs (let’s call this website 1) to the homepage of a new website (website 2). This is something we do not recommend, especially for large websites, because you would be redirecting so many URLs to one destination. It’s much better to map the URLs from website 1 to the most relevant pages on website 2.

If however you do choose to redirect a full domain to the homepage of another site you can do this as follows:

Redirect from and all their URLs to

RedirectMatch 301 (.*)

Redirect the homepage to another URL

If we want to redirect the homepage of our domain to an internal section of the web or to another section of another web such as to the code would be something like this:

RedirectMatch 301 ^/$

Redirect a full directory

If we want to redirect a full directory to another one e.g.: to this piece of code would make it possible:

Redirect 301 /directory/

Also if we want to redirect from a subdirectory like to

Redirect 301 /directory/subdirectory/

Redirect a specific page

If we want to redirect only a specific page like to

Redirect 301 /page-x

How to check a 301 redirect

To review the 301 redirect has been implemented correctly simply type the URL you have redirected and see if this now points you to the new corrected page.

It’s also very important to check the URL returns the 301 code. You can do this by using a tool like Screaming Frog Spider or using this free online redirect checker You will only have to insert the redirected URL and check all seems correct.

Conclusions about redirections

301 redirects are a vital part of any SEO audit and when implemented correctly can positively impact user experience, SEO and conversion rates.

This guide is inspired by the redirect guide from Spanish SEO David Ayala.

If you have any questions about redirects or need us to help you implement them, then get in touch with us today!

Created by

Alexis Pratsides

Published at 

More insights from the team