Design Freebies, Tools and Inspiration
Tools

Create a SEO Friendly 301 Redirect With .htaccess

301 Redirect Tutorial

There are situations when you need to create redirection from one page to another page, and the best way you can do this is with a 301 redirect. These situations can appear when you change the Url paths of your website. So why would you redirect them? Well maybe you have a valuable article or resource that attracts a large amount of traffic. You will want to maintain this traffic and direct the users to the new path.

Of course, you would want to do this in the most efficient and non-intrusive way for your users. An important thing you should also consider is where does search engine optimization come in this situation.

There are a number of ways you can do a redirect, through Apache, cPanel, with HTML or .htaccess. The easiest way, and the one we will be covering in this article is .htaccess redirect. We will be covering other ways to make a redirection in future articles.

There are 2 SEO friendly redirect types :

  • 302 temporary redirect
  • 301 permanent redirect

The recommended redirect type, also liked by Google is, of course, the 301 permanent redirect.

301 redirect

As I said there are a number of ways you can make a 301 permanent redirect, but the easiest is with your .htaccess file.

1. Locate or create the .htaccess file

If you dont have a .htaccess file, you will need to create one. The location of this file must be in the root of the domain you are trying to make the redirect on. Lets use an example domain for this tutorial : www.example301.com.

So to recap, your .htaccess file needs to be here :

http://www.example301.com/.htaccess

If you already have this file, you can skip this step.

2. Adding the 301 redirect to the .htaccess file

Once you created / located the .htaccess file, you will need to add a line of code to it. If you already have the file, add the line at the end of the file and make sure you dont edit anything else. If your .htaccess file is empty, you can add the line of code to the first line of the file.

I will use two examples to illustrate the code you need to add to your .htaccess file. The first refers to blog Urls and the second to individual HTML files.

301 Redirect Example 1

For example purposes lets consider we are trying to redirect this page :

http://www.example301.com/a-beautiful-article-address

to

http://www.example301.com/another-beautiful-article-address

The line you need to add in the .htaccess file is this :

Redirect 301 /a-beautiful-article-address http://www.example301.com/another-beautiful-article-address

As you can see the beginning of the line tells the parser we are making a redirect. The second part indicates the address we are redirecting and the new address we are redirecting to. Notice the first address is in absolute path (without http://www. ) and the second path isnt. This is very important in order to make this work.

301 Redirect Example 2

Lets say you are trying to redirect a specific HTML file like :

http://www.example301.com/portfolio.html

to

http://www.example301.com/new/portfolio.html

In this situation the line you need to add in your .htaccess file is :

Redirect 301 /portfolio.html http://www.example301.com/new/portfolio.html

And that is it. All you have to do is to check your 301 redirect works. You can do this with a redirect checker like redirect-checker.org or redirectcheck.com. Hope you found this 301 redirect tutorial useful. If you have something to add please comment below.