What is a 301 Redirect?

If you have deleted some pages or moved some of your content to another webpage, you’ll want to do a 301 redirect. A 301 redirect is a simple line of code that directs the search engines to where your page has moved. By doing this, you can easily redirect traffic, rankings and backlinks to another page. This is effective if you don’t want your ecommerce marketing to go to waste.

While 301 redirects are simple to understand, they can be quite complicated to implement. This is true especially if you don’t have any knowledge with fiddling with the root folder of your domain. It involves terms like .htaccess, Apache and mod_rewrite. If none of these sound familiar to you, don’t worry. I will try to explain 301 redirects in the simplest way possible.

What is a 301 Redirect?

As mentioned, it is a line of code that redirects search engine robots. Think of it as an arrow on the closed road. When the search engine robots reach your page, the 301 redirect immediately signals the robots to take another way for that path is closed.

Where you direct it is entirely up to you. You can redirect the robots to another page that contains the same content. But if you like to delete some pages, you may want to redirect them to the homepage of your site instead.

How is a 301 Redirect Implemented?

301 Redirects can only happen if you have a line of code in the .htaccess file in the folder of your root domain. You can find this when you visit your cpanel and go to File Manager. You’ll see a file called “.htaccess” in the public_html folder. Public_html pertains to the root folder of your domain. This is where all of your main files are contained.

Now there are some instances that you may not find the “.htaccess” file. When this happens, you can always create one or look for hidden files. If you really cannot find it, creating one is easy. Just open a Notepad file and save it as “.htaccess”. Just leave it blank. Upload it to the public_html folder and you already have your file. This is where you can put your 301 redirect commands.  

Why do a 301 Redirect?

Here’s a secret. Search engines speak in codes. The robots will not be able to understand you unless you speak their language. This is the reason why you have to go through all the trouble of creating your .htaccess file. This is the reason why you have to give your commands within that file. The .htaccess file is the file accessed by the search engines. It follows its commands.

But more than directing search engine robots where to go, it also directs them to the pages that must be indexed. Once a page is down, the search engines will not be able to immediately take it down from the search engine results. With a 301 redirect, the robots will understand that the page is closed and there is a new page that must be indexed instead.

WARNING: Having the Wrong 301 Redirects Can Hurt Your Website

Before attempting any 301 redirect on your site, it is very important to know where you want the redirects to go. Don’t just do it just because you like to try it. Once you set up a redirect, your traffic, backlinks and rankings will immediately go to the new page. So if you have included a wrong page, it can hurt your site and your business.

Fortunately, there are some things you can do to ensure that your website stays on the safe side.

1. Backup Your .htaccess File

Don’t do your 301 redirects without your old file. Download your old .htaccess file from the public_html folder and keep a copy of it. This is a must if the .htaccess file also have other commands in it. This will prevent you from losing your old file.

2. Test the Redirects in a Dummy Site

Before you implement the 301 redirects in your account, it may be better to have a dummy site or page to test it. Simply duplicate your site using the Duplicator plugin and install it in a subdomain or folder. Be sure to block all search engine traffic for this will tag your site as duplicate. Then, start testing your redirects. Just visit the pages that you have redirected and try to see the pages that you land in.

3. Test Category and Archive Redirects as Well

It is important to not only test the raw URL. In WordPress websites, you also need to see if the category pages and archive pages are also redirected as well. So be sure to also check that. If you have thousands of pages, you may not be able to check everything. But test a good number of links and this will help you catch some errors. Your page may also have variations of the URL that you have to test. This will let you see if the redirect is working well.

4. Automatically Crawl Your Site for Errors

There are some tools that you can use to track the errors in a site. This will help you uncover pages that have an error that you may have not noticed. These tools are great because you don’t need to check the links manually. You can just plug in your site and the tool will look for all the error pages.

5. Launch Redirects in Low Traffic

When you are ready to launch your .htaccess file, do so in a time of low traffic. Search engines can work really fast. You don’t want to commit an error right when people are visiting your pages. If the 301 did not work, your visitors will see a “500 Error” instead. By launching this in a time of low traffic, you can see if it is generating any error and act accordingly.

6. Know How to Go Back to Your Old .htaccess File

If all else fails, know that you always have your old .htaccess file. But only do this if you cannot seem to get the redirect to work well. It just feels safe that you have old file with you in case things go wrong. Also, learn to give it time. While the search engine robots may work fast, it cannot index thousands of pages in a single day. Only revert to your old .htaccess file if you find that you have the dreaded “500 error” for you don’t want your entire site to have an error right from the search engines.

When to Use 301 Redirects?

Now that you have a general idea of 301 redirects, you are probably thinking that you should only use it if you are redirecting a webpage into a new page. But that is not the only application of 301s. In this section, you’ll learn about the different ways on how you can use 301 redirects.

Redirecting to a New Page

This is probably the scenario that entered your mind when you think about redirect. It is about redirecting an old link to a new link. It can be a page such as “www.oldsite.com/old.html” to “www.oldsite.com/new.html” or it can be a to another page in a new site such as “www.oldsite.com/old.html” to “www.newsite.com/new.html”.

To do this, the command is.

Redirect 301 /old.html http://www.newsite.com/new.html

There’s no need to spell out the old site for it is understood by the page since the .htaccess file is in the root folder of the domain.

Redirecting to a Page Without Extension

301 Redirects work for more than just webpages with extension. You can also use it for those without extensions such as http://www.newsite.com/new. See? No .html. This is also quite common for pages for WordPress and Joomla.

The command is as follows.

Redirect 301 /old http://www.newsite.com/new

It’s that simple.

Redirecting to a New Home Page

Changed your domain name? No problem! You can also redirect the entire site to a new domain name. For this, you have the following command.

RedirectMatch ^/$ http://www.newdomain.com

Changing Your Site to Include www

If you have decided to include www in your site’s URL, you’ll also need to implement a 301 redirect. For this you need to redirect the URL without “www” to one that have “www”.

For this, you have the following commands.

Options +FollowSymlinks

RewriteEngine on

RewriteCond %{HTTP_HOST} ^site.com [NC]

RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]

Why do you need to do this? Search engines tag sites without “www” to be similar to the one that does. This means that you are at risk of duplicate content. The NC above stands for non-case sensitive. This means that any capitalizations done on your domain will also be covered. This command will also properly redirect any type of link whether if it has “www” or not.

Renaming a Category

When you rename a category, you’ll want to redirect the old category link to the new category link. You need to do this so that you don’t lose the backlinks and traffic in the old category. The command is easy.

Just input this in your .htaccess file.

Redirect 301 /oldcategory http://site.com/newcategory/

Redirecting to a Deeper Category

You may have transferred your category inside another category. For that, you’ll need to only input the longer link with deeper category. The command is the same but the link is different.

Redirect 301 /oldcategory http://site.com/parentcategory/all/newcategory/

Redirect Category Pages to a New Page or Folder

If you are planning to delete pages in bulk, you may want to redirect all the old links to a particular page. It can be hard to do this one by one. But you can set up a command in .htaccess that will redirect all of them to your desired page.

For that you have this command.

RedirectMatch 301 ^/oldcategory/(.*)$ http://www.site.com/newpage

Or if you want to redirect to a folder. You can do this.

RedirectMatch 301 ^/oldcategory/(.*)$ http://www.site.com/newfolder/

This redirects all the pages inside the oldcategory to your desired page or folder.

Redirect Category Pages to a New Page with Extension

The strategy above also works for pages that have an extension. You can just append .html in the end. You can use this command instead.

RedirectMatch 301 ^/oldcategory/(.*)$ http://www.site.com/newpage.html

It’s that simple.

Redirecting the Entire Domain

Now redirecting to a new domain name is more than just redirecting the home page. You’ll also need to redirect all the other pages within that domain name. This way, the traffic that you use to get will all go to the new domain name. For this, you need to use the following command.

Options +FollowSymLinks

RewriteEngine on

RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

NOTE: This can only work if your Apache Web Server has mod_rewrite on. If you don’t know how to turn this on, simply include the code “RewriteEngine on” in your .htaccess file. Just type it in a new line and save your .htaccess file.

ANOTHER NOTE: This is a really lazy way to redirect an entire website, you may also need to redirect the individual folders so you need to test them one-by-one. You may also need to check some pages from the old domain to see if they are really redirecting.

301 Redirects in Action

Now that you know the code, it is time to create your own .htaccess file command. Here is an example.

Options +FollowSymlinks

RewriteEngine on

RedirectMatch ^/$ http://www.newdomain.com

Redirect 301 /oldcategory/oldpage-1 http://www.newdomain.com/newpage

Redirect 301 /oldcategory/oldpage-2 http://www.newdomain.com/newpage

Redirect 301 /oldcategory/oldpage-3 http://www.newdomain.com/newpage

Redirect 301 /oldcategory/oldpage-4 http://www.newdomain.com/newpage

Redirect 301 /oldcategory/oldpage-5 http://www.newdomain.com/newpage

RedirectMatch 301 ^/oldcategory-2/(.*)$ http://www.newdomain.com/folder/page

RedirectMatch 301 ^/oldcategory-3/(.*)$ http://www.newdomain.com/folder/page

The file may be longer if you have tons of pages.

Questions? Feel free to ask them below. 

7 Response to "What is a 301 Redirect?"

  1. Comment From Angelina Torres

    It’s my first time to learn about 301 redirect. Your articles really help us learn a lot of things. Thank you.

  2. Comment From Carmina Courtney

    I just learned now that having it wrong could do more harm than any good. I would definitely share this article to my friends, more people should know.

  3. Comment From Dylan Crow

    Remember to test after redirecting! A lot of people forget about doing that.

  4. Comment From Veronica Dashton

    Really informational article. I wanted to know more about this and you really filled me with more knowledge in a simplified form.

  5. Comment From Jameson Smith

    It’s that simple to turn on the apache web server? I had to call someone to fix it, I can’t believe it was very easy.

  6. Comment From Jennifer Curtis

    I wish I knew this before, it would’ve made a difference. But thanks because I know this now.

  7. Comment From Kimberly Smith

    Wow, this is such an informational article about 301 redirect. It would definitely help a lot of people. Totally worth the share.

Leave a Reply

Your email address will not be published. Required fields are marked *