301 redirect – How to Properly Implement 301 Webpage Redirection

A 301 redirect is an essential resource for moving, deleting, and consolidating pages. A 301 redirect is the most efficient and Search Engine Friendly method for redirection of old URL to new one. The code “301” is interpreted as “moved permanently”,  it’s the safest option and easy to implement.

A 301 redirect is the easiest way to send both users and search engines to a different URL.

There are many reasons of redirection, here are some why it is essential to perform this type of action:

  • Problems with duplicate content. if You have the same content in different URLs of your Site.
  • The desire to modify the structure of the URLs of your Site.
  • The content of an URL has become obsolete and you want to register a new URL with the new content.
  • A product has expired and you have generated a new product.
  • Change the place of a domain.

It’s often mentioned as a solution for SEO problems. Which say, “Make a 301 redirect and fixed,” but … How do you do it if you have no idea? No problem. In this guide, I will teach you to make 301 redirects for any situation that you are in.

301 redirect - How to Properly Implement 301 Webpage Redirection

What is a 301 redirect?

A 301 redirect is no more than a program command which sends users/visitors and search engines bots from an URL to another URL permanently and automatically.

You can move a single page of your site, a directory, or even the entire domain. A 301 redirect automatically forwards visitors who arrive through the old address to the new one.

301 redirect is a safest program command used to tell the search engines that a web page has permanently moved and want to index the new page URL and Delete the old one from their index.

Users/visitors have the unpleasant experience of reaching a page that does not exist ( the famous error 404 ). It helps search engines to update their indexes with new URLs.

Redirects 301 are useful when:

  • You want to change the URL of a page or delete it.
  • You have duplicate content issues.
  • Receive visits or links in URLs that no longer exist.
  • You are going to change the content manager or CMS.
  • You need to establish the canonical version of your site.

Types of Redirections

There are 3 types of redirects that you should know:

  1. 301, “Moved Permanently”—recommended for SEO
  2. 302, “Found” or “Moved Temporarily”
  3. Meta Refresh
  • 301 redirect: This type of redirection can be defined as “PERMANENT“. This means that all content in an old URL is permanently moved to the new URL. In this way, the search engines will no longer take the old URL and they will transfer to the new Web page.
  • 302 Redirection: This type of redirection can be defined as “TEMPORARY“. This means that all content in an old URL is temporarily moved to the new URL. This way we can redirect the search engines and users of the old URL to the new one.
  • Meta refreshes: This type of redirections are usually slower, and not a recommended SEO technique. Meta refreshes are a type of redirect executed on the page level rather than the server level.  They are most commonly associated with a five-second countdown with the text like  “If you are not redirected in five seconds, click here.” Meta refreshes are not recommended due to poor usability and the loss of link juice.

Why 301 redirect important?

There are several ways to redirect, such as meta refresh or JavaScript. However, the only one that passes the test of the search engines that is the 301 redirect. I always recommend following the Google recommendations.

The difference is that a 301 redirect transmits the entire link value from the old URL to the new one. And this would not be important except because search engines calculate the popularity of a page based on links.

When a search engine encounters a 301 redirect, it reacts like this:

  1. Remove the old page from your index – This way that page will not appear again in the search result pages.
  2. Include the new page in your index – This means that all content in an old URL is permanently moved to the new URL. And search engine index the new page link.
  3. Transfer the value of the old page to the new one – It affects the popularity of page links, which directly affects the rankings.

If you want to move content and you are concerned about SEO, you should use 301 redirects before anything else.

How to do 301 redirect?

301 Redirects Using .htaccess for Apache

A 301 redirection is easy to implement. Simply edit a file on your server named .htaccess and enter the required commands.

.htaccess is a file that controls the configuration of the server. It is located at the root of your site and is the first thing that is loaded when a user/visitor accesses your site, even before the page appears.

If you have an Apache server: you can edit the .htacces document located in the root of your web storage. However, you have to be very careful because an error in editing this document can cause the fall of the website for a while.

To enter 301 redirects in the .htaccess file, follow these steps:

  1. Find the .htaccess file – Connect via FTP to your server (you can use FileZilla or CyberDuck ) and look for the .htaccess file  (usually it is in  / www / , / httpdocs / / public / or  / public_html / ). Note that this is a hidden file, so you must activate the option to see all the files in your FTP client.
  2. Open the file – with any text editor such as Notepad or Notepad ++.
  3. Edit the file – Following the instructions below.
  4. Saves the file – With ANSI coding to avoid errors.

The .htaccess file is a serious matter. If you make a mistake when editing it can cause a disaster in your website, so treat it with respect.

I recommend taking these precautions:

  • Make a backup of the file before making any changes.
  • Do not change a single line in this file, unless you know what you do.
  • Test each and every one of the redirects entered, including individual pages, directories, etc.
  • Make these changes in the fewer traffic hours.

How long to leave the 301 redirects?

In theory, a 301 redirection is permanent and should be left configured forever. But it is difficult to maintain a redirection forever.

The search engine can take between 6 months and a year to recognize that a site has changed direction.It’s recommended that keep the redirects active for at least a year.

Therefore, if you have moved your site or certain page and search engines recognize that the redirection is permanent (which may take the half year or a year), then you can remove the redirection to a certain extent.

On the other hand, if you delete the redirects and your old URLs are linked, they will lead to a 404-page error. Prevent the user/visitors from having this bad experience, referring sites to update links. Google has a guide that explains the steps to follow.

In short: keep redirects as long as possible for at least a year, and make sure the links to your site are upgraded to the new version.

Several types of redirects

To configure the .htaccess and begin to enter the relevant redirects you need to know what kind of redirects can be configured. When making redirections you can find yourself with very varied situations, and not all are solved the same.

Here are several types of redirects.

  • 1.Redirect a page
  • 2. Redirect a directory
  • 3. Redirect a domain
  • 4. Redirect an IP
  • 5. Redirect from NO-www to WWW
  • 6. Redirect from HTTP to https
  • 7. Redirect the slash to the end (/)

Let’s see them:

Redirect a page

If you want to move a page from one address to another without further. It is a very common action when you want to redirect one page to another for following reasons.

  • Rename URL
  • Move content to another page
  • Delete page

The redirection would look like this:

Redirect 301 / old-page http://www.example.com/new-page

Notice that the first URL does not include the domain and the other does. The advantage of this syntax is that you can move the page only not the whole domain.

But if you want to move only the main page of your site to an internal page or another domain.

Then the redirection would look like this:

RedirectMatch 301 ^ / $ http://www.example.com/new-page

Redirect a directory

Suppose you have a directory on your site that hangs with other directories or pages, and you want to move it to a directory with another name.

The redirection would be this:

Redirect 301 / old-directory / http://www.example.com/new-directory/

Notice that you can redirect first level directories with its subdirectories. The only thing you would have to do would be to include the complete directory structure up to the level.

Redirect 301 / directory / old-subdirectory / http://www.example.com/directory/new-subdirectory/

Another interesting case would be to move a directory to a deeper subdirectory.

Redirect 301 / directory / subdirectory / http://www.example.com/directory/new-subdirectory/subdirectory/

Now suppose you have a directory that hangs internal pages and you have decided to get rid of that directory and everything it contains. This would be the proper redirection:

RedirectMatch 301 ^ / old-directory /(.*)$ http://www.example.com/new-page

Redirect a domain

If the name of your domain no longer makes sense, and you have to move it to another with a more appropriate name. Just want to rename it.

You would do it like this:

Redirect 301 / http://www.example.com/

If you want to redirect all the content of the old domain to the main page of the new one:

RedirectMatch 301 (. *) Http://www.example.com/

When moving a site from one domain to another, you must remember to renew the old domain along with a hosting plan to continue retaining the redirects. If you forget and you do not get the links that point to the old domain change to the new one, you will lose the link juice that you have accumulated.

Redirect an IP

It is often forgotten that the IP address of a site should be redirected to the URL of the domain. Otherwise, search engines can confuse and index a replica of your site for the server IP, which is undesirable.

To redirect the IP of domain server uses the following rule:

<IfModule mod_rewrite.c>
 RewriteCond% {HTTP_HOST} ^ 198 \ .51 \ .100 \ .24
 RewriteRule (. *) Http://www.example.com/$1 [R = 301, L, QSA]
 </ IfModule >

When configuring the redirection, remember to change the IP of your server. You can get it from the SpyOnWeb tool.

Redirect from NO-www to WWW

To avoids the redirection problem of having 2 versions of a website, one in the version www.example.com and another in the example.com version (without www ).

<IfModule mod_rewrite.c>
 RewriteCond% {HTTP_HOST} ^ example.com [NC]
 RewriteRule (. *) Http://www.example.com/$1 [R = 301, L, QSA]
 </ IfModule>

In that case, the WWW redirect to No-www would look like this:

<IfModule mod_rewrite.c>
 RewriteCond% {HTTP_HOST} ^ www.example.com [NC]
 RewriteRule (. *) Http://example.com/$1 [R = 301, L, QSA]
 </ IfModule>

Redirect from HTTP to https

If you have a secure web that works only with SSL, it is good to make sure that your pages are always served from the HTTPS protocol.

To do this, it uses the following rule:

<IfModule mod_rewrite.c>
 RewriteCond% {HTTPS} off
 RewriteRule (. *) Https://www.example.com/$1 [R = 301, L, QSA]
 </ IfModule>

If you decided to remove the SSL certificate, you’ll need to redirect to the HTTP version. Otherwise, your users will encounter an annoying error message in the browser and you will lose visits.

Here’s the rule:

<IfModule mod_rewrite.c>
 RewriteCond% {HTTPS} on
 RewriteRule (. *) Http://www.example.com/$1 [R = 301, L, QSA]
 </ IfModule>

Redirect the slash to the end (/)

It may happen that your pages are available with a bar(slash) at the end or without it. For example:

  • Http://www.example.com/page
  • Http://www.example.com/page/

If so, you have a duplicity that can only be resolved by redirecting one version to the other.

To redirect all pages without a slash to the slash version at the end, use the following rule:

<IfModule mod_rewrite.c>
 RewriteCond% {REQUEST_FILENAME}! -f
 RewriteCond% {REQUEST_URI}! (. *) / $
 RewriteRule (. *) Http://www.example.com/$1/ [R = 301, QSA]
 </ IfModule>

And thus remove the end bar(slash), use this other rule:

<IfModule mod_rewrite.c>
 RewriteCond% {REQUEST_FILENAME}! -d
 RewriteRule (. *) / $ Http://www.example.com/$1 [R = 301, L, QSA]
 </ IfModule>

Essential for redirections

To make sure that the redirects work which implemented on the .htaccess file, on an Apache web server, and with the mod rewrite function enabled.

To do this, include the following code at the beginning of the file:

Options + FollowSymlinks
 RewriteEngine on

Just copy the commands (renaming the pages, directories, and domains) and just paste them below.

Alternative Methods to Implement a 301 Redirect

If you don’t have access to the .htaccess file, you can still implement 301 redirect with some coding on old web pages. If your web pages are in Java, HTML, PHP, ASP, or any other language that allows modifying response headers. Then simply place code at the top of the page to do the permanent 301 redirect.

Here are some methods to implement URL Redirection (301 redirects) via codes without editing .htaccess file.

JSP (Java) Redirect

response.setHeader( “Location”, “http://www.newsiteurl.com/” );
response.setHeader( “Connection”, “close” );

PHP Redirect

Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.newsiteurl.com” );

ASP Redirect

<%@ Language=VBScript %>
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.newsiteurl.com/”





Leave a Reply