A Web.com Partner

What is an htaccess 301 redirect?

This tutorial describes what an htaccess 301 direct is and when it should be used.

After upgrading your website or blog you may find that some of the URLs and paths on your site have changed. When this happens, it is possible that visitors to your site to get 404 File Not Found error when coming from search engines, external links and bookmarks where the destination address has changed.

There are a couple of ways to redirect traffic so visitors to your site are non-the-wiser to your site’s redesign. The most effective and search engine friendly way to do this is by using an htaccess 301 redirect.

It is important to note that when you’re about to redirect your content to a new server or to a new domain its best to avoid complicating things with changing your file structure at the same time. If you change your domain name and your catalogue structure at the same time you will have a huge mess on your hands, especially if your are moving servers at the same time.

It is best practice to redirect one step at a time and carefully deduce whether or not additional changes have to be made. Please keep those changes to the very minimum and keep in mind functionality, SEO value etc before making any changes.

What ihtaccess1-smalls an .htaccess file?

When a visitor requests a web page via any means, your web server checks for a .htaccess file. The .htaccess file contains specific instructions for certain requests, including security, redirection issues and how to handle certain errors.

What is a 301 redirect?

The code “301” is interpreted as “permanently moved”. After the code, the URL of the missing or renamed page is noted, followed by a space, then followed by the new location or file name. For example if you want to redirect mydomain.com/old/old.html to mydomain.com/new.html then the line in the .htaccess file should read

redirect 301 /old/old.html http://www.mydomain.com/new.html

How to implement a htaccess 301 redirect

  1. You first need to download the .htaccess file in the root directory of where all your web pages are stored. If there is no .htaccesss file there, you can create one with Notepad or a similar application. Make sure when you name the file that you remember to put the “.” at the beginning of the file name. This file has no tail extension.
  2. If there is a .htaccess file already in existence with lines of code present, be very careful not to change any existing line unless you are familiar with the functions of the file.
  3. Scroll down past all the existing code, leave a line space, then create a new line that follows this example:
    redirect 301 /old/old.htm http://www.mydomain.com/new.htm
  4. That’s it! That’s all you need to add. Now save the file and upload it back into your web server and test it out by typing the old address to the page you’ve changed. You should be instantly and seamlessly redirected to the new location.

Notes: Be sure not to add “http://www” to the first part of the statement – just put the path from the top level of your site to the page.

htaccess2-originalRedirecting entire sites with .htaccess 301 redirects

Say you have changed your domain name and want all traffic from old site to be directed to the new site. This too can be done with 301 redirects, eg.

redirect 301 / http://www.mydomain.com/

The first “/” indicates that everything from the top level of the site down should be redirected. As long as you are using the same paths and filenames, then this option is a very simple way to perform site redirection in the situation where you have only changed your domain name.

If the site redirection doesn’t work for you, check to ensure you have the trailing “/” on the destination URL.

SEO Benefits of 301 Redirects htaccess3-small

Search engines place more emphasis on web pages which have received ‘external votes’ or links from other websites – particularly from sites which have authority and relevance.

Therefore, it is essential to either retain the existing page URL’s when redesigning an existing website, or if a new URL page structure is implemented it is necessary to 301 redirect all of the old page URLs to the corresponding new pages to ensure that traffic and search engine ranking is not lost.

By implementing htaccess 301 redirects, the search engine value of any external links to the original page(s) is retained and hence full search engine ranking is transferred to the new page – assuming that the new page is on the same domain.

A htaccess 301 redirect, when implemented properly also helps the search engines index the new page, whilst removing old content from the Google index faster.

Testing htaccess 301 Redirects

To test that the .htaccess file is working and that each page is being redirected correctly, we recommend testing each 301 redirect using a Web Page Header Check on the redirected page URL’s. The returned headers should show any 301 redirects that have been implemented for each redirected URL in the .htaccess file.

x
Chat