Redirections are an essential part of any website’s SEO strategy. Whether or not you currently use a redirect on your website, you could be hurting your website’s standings with Google and risking a penalty. The fact is, there are times when using a redirect is absolutely essential to your website, and there are uses of redirects that can hurt your website as well.
When a Redirect is Absolutely Necessary
Website owners commonly make the mistake of not setting up a redirect when they move a page on their site or change the domain of their site. Failing to setup a redirect will not only cause confusion for visitors who try to access an old URL, but it can also confuse the search engines if proper instructions are not given to them. Your SEO company should be involved in correct this.
Most website owners at one point or another will move a page, or even an entire site. It might be a slight move, such as changing the name of a directory or a file name. Or it may be a more significant change, such as converting your site from older HTML files to more modern PHP or ASP files. In some cases, the change may be drastic, changing the very structure and navigation of the website. In each of these examples, it is essential that you setup the proper redirection to avoid receiving a penalty from search engines.
The 301 Redirect
Anytime you move a page, or change the URL that is used to access a specific page or set of pages, you need to setup a 301 Redirect.
The Internet is setup with a variety of codes and status responses that tell web browsers how to act. If you are reading this article on the Internet, then your browser came upon this page and was given the code 200, which simply means ‘O.K.’. There are a whole variety of responses which are not important to understand for this article, but if you are curious, you can find an entire list of responses by going to the W3C Status Code Definitions site.
The 301 status tells the browser that the page has been moved – permanently. This is extremely important to search engines as it tells them to update their database with the new link and to drop the old link. If you changed the location of a page on your website, you want this to happen.
One of the trickiest things to avoid when continuing to build your site is the duplicate content trap. As your website grows, and as you move pages around, it is easy to leave the exact same page, or two pages that are nearly identical, accessible. While having two pages that are essentially identical does not necessarily hurt your website from a visitor standpoint, it can be misinterpreted as spam by Google, and thus they may penalize your site for having duplicate content. It is for this reason that Google recommends using a 301 redirect.
Whenever you change the location of a page on your website, it is extremely important that you tell web browsers and spiders that you have permanently moved the page. Of course it follows that you need to tell them where you moved the page to
Setting Up a 301 Redirect
Properly setting up a redirect can be very easy to do if you have a relatively small site or simple redirection. However, if you have a large website or are changing the way you link to your pages, setting up a redirection can be complicated.
The examples listed here assume that you are running on an Apache webserver. If your website is running on a Windows platform, you should contact your webhost to figure out how to setup a 301 redirect.
The .htaccess File
If You Are Simply Moving a Page
If you are simply moving a page or a directory from one place to another, setting up a redirect is relatively easy to do. Open up your .htaccess file (or create a new file that you will call .htaccess) and paste in the following line:
Redirect 301 page.html http://www.joomquery.com/somenewlocation.html
In the above line all you need to do is replace the ‘page.html’ with the page or directory that is being moved and replace the ‘http.://www.somesite.com/somenewlocation.html’ with the location of the new file. That’s all there is to it! A search engine spider will now know that if it tries to access page.html, it should update its listing to the new location given. This could also work for changing your domains as well. If you are changing domains, you would write:
Redirect 301 / http.://joomquery.com/
If You Are Changing from HTML to PHP or ASP
As technology improves, so should our websites. This often requires that we change the technology that runs our websites. Many websites started out as plain HTML but later find the need to move to PHP or ASP to give their users the best experience possible.
There are a few options availabe in this situation. The solution we will offer is using a technology called mod_rewrite. Mod_rewrite is a simple technology that is used to rewrite URLs at the server level. Sound confusing? It really is not too difficult to understand. Simply put, mod_rewrite can make this url:
accessible to your users by linking to:
You do not have to change your files around at all, just create a rule. We can use mod_rewrite to setup a redirect for multiple pages on our website. Let’s suppose that we are changing every page on our website from a .html to a .php. To do this, we would once again open our .htaccess file and put in the following code:
RewriteRule ^(.*).html$ $1.php [R=permanent,L]
Whoa! Now that looks a little more confusing than the first rule. Mod_rewrite can be difficult to master if you are not familiar with things like ‘regex’, but rest assured that the code above is not too difficult. It would be beyond the scope of this article to go into depth on what each one of these lines means, but you can find some great resources by going to the forums at modrewrite.com for more information.
Using PHP and ASP to Redirect
For those users who are drastically changing their website’s structure, they may find that using mod_rewrite or a simple apache redirect just does not cover all their bases. An example of this could be a blog owner who decides to change the links to their posts from this:
It would be unrealistic to try and enter a redirect rule for every post that this person has made in the past, and the URL’s do not share any of the same information, which makes it impossible to use mod_rewrite alone. In a case like this, it is necessary to fall back on a script that will take the old URL, feed it to a script which in turn will provide the official redirection.
Both ASP and PHP have the ability to provide a 301 redirect to browsers. To redirect a browser or spider with PHP or ASP, you should use the following code: