Custom Search

Kamis, 09 April 2009

301 & 302 Redirect in htaccess


"Is canonicalization sabotaging your website's performance? Find out how to fix/avoid this common issue with 301's & .htaccess"
Moving pages or remodelling? Have you decided to move your site to another domain? Do you want to move a cluster of files to another directory within your domain? Or do you want to move an entire directory to another location on your server? For example maybe you have a blog incorporated into your site and would like to move it to a subdirectory? URL redirecting is really about the art of sending a visitor (spiders and humans) to another location, often a new URL location.
For many reasons, it's becoming more common these days for webmasters to want to update their sites - some for seo purposes, much of which involves restructuring a sites architecture. Usually when a sites architecture changes, pages and directories move to different locations on the server. When pages get removed from their previous location and no page is left to replace it, the location becomes non existent. Visitors to the location will have no where to go (the nasty 404 error messages) and for your human visitors it can become frustrating, resulting in leaving your site to the point of no return. And this is of course not what you want, so to avoid this type of issue learn to setup a 301 redirect. Below we'll examine what they are and how you can use them on your site(s).
Before we begin it's important to note there are two types of redirects; 301's and 302's both of which share a common purpose however are distinctive of one another. Basically a 301 redirect refers to a permanent redirect, or what other experts may refer to as a hard redirect, whereas a 302 redirect refers to a temporary redirect, or soft redirect. One of the most effective ways to redirect your visitors from a location on your site that no longer exists to where you intended for them to land is to implement a 301 redirect. Don't be discouraged by its technical label, although it does sound kinda cool, as it's really quite simple. 301 redirects serve to inform visitors to your site that a requested page has been moved permanently and is now situated at a new location.
How do you implement a 301 redirect? First there are several ways to implement a 301 redirect and this can depend on what type of server your hosting is operating on. For example 301 redirects are setup differently if you're working with an Apache web server or a Microsoft IIS Web Server. To complicate things a little more, 301 redirects can also be written differently if you're setting it up in PHP (hypertext preprocessor) or in ASP (Active server pages). To find out how to do 301 redirects in Apache .htaccess, IIS, PHP, ASP, and Cold Fusion I'd suggest following the link. I've done the homework for you and cross referenced these scripts with W3 Schools and they are very identical. Thus, if implemented correctly they do work.
To configure a 301 redirect for an entire site in .htaccess include the following code in the .htaccess file in the root of the old site:
Redirect 301 /http://www.newdomian.com
This will allow all URL's pointing to the old domain to be redirected your new domain. However if you wish to only redirect a single page or a set of single pages you can also use the following 301 redirect in .htaccess.
redirect 301 /old/old.htm http://www.domain.com/new.htm
Advanced SEO technique tip: Did you know that a lot of webmasters and site owners out there are oblivious to the fact that much of their websites content is unnecessarily duplicated by the search engines? In fact there seems to be a consensus among other SEO experts about such SEO best practices. It seems that many have unanimously adhered to the fact that the top search engines have not yet correctly fixed the canonicalization issues with the [www] and [non-www] version your site (i.e. the search engines still consider http://www.amanticode.com and http://amanticode.com to be separate which can lead to the problem of duplicate content.
Canonicalization: "The process by which URL's are modified and standardised in a consistent manner"
This can mean that link 'juice' to these (same) pages is actually split between them which can mean lower search engine rankings. How can you correct or avoid this common issue?
Simply put, utilising .htaccess to redirect specific requests for pages on (or no longer) on the server aims to find that request and if so, forwards the visitor to the page you have specified. In order to correctly execute this, I would highly recommend implementing the following 301 redirect to your .htaccess file.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
This code will instantly and automatically eliminate the potential problem of duplicating your webpage's content by informing the spiders that both URL's reach the same webpage.
Server side SEO experts suggest;
"While implementing 301 redirects on Linux/Unix servers using .htaccess be careful, as sometimes even a small mistake can be hazardous to your site, you will also have to keep patience as spiders take time to understand the changes in your URL structure to register in search engines. After applying a redirect you should inform the change to your link partners so they can make any necessary adjustments"
To implement a 302 redirect in .htaccess file, assuming the web server allows it, it is easy to implement a 302 redirect in .htaccess. Just implement the following code(s):
Redirecting a page
Redirect /file-name.html http://www.yourdomain.com/tempdirectory/temporary-file-name.html
Redirecting a directory
Redirect /directory http://www.yourdomain.com/tempdirectory/
Redirecting an entire site
Redirect / http://www.temporary-yourdomain.com/
Overall for the best Google and SEO results it's best to use a '301 redirect' rather than a '302 redirect' although it depends on the reason and intention for your redirects.

0 komentar:

Labels

Social Bookmark

My BlogCatalog BlogRank Subscribe with Bloglines
 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com Distributed by Deluxe Templates