“Website redirection” means that when a user goes to one of your web pages, you automatically lead him to another site (or page). This is particularly useful if you have changed your domain name or site structure.
In chette.com, you would notice that I use this. If you go to the URL www.chette.com, you are actually redirected to www.chette.com/main. Main is a folder in my public html. I put my content files in subfolders in order to keep my public_html directory neat, and to enable me to test an upgraded CMS before making it accessible to the public.
The old-school way of redirection was thru the infamous meta refresh tag. However, websites which contain this tag are already being tagged as spam by search engines.
A better alternative is to use a 301 or 302 redirect. These are called response codes. A more technical definition is available, but in a nutshell, if you use a 301 or a 302 redirect, you are just automatically directing your visitors to your new URL.
301 returns a user-agent response that your website has moved permanently to a new location. A 302, on the other hand, returns that your website has only moved temporarily.
What to use
There are a lot of arguments on 301 vs. 302. Some would favor one over the other, claiming that 302 should be strictly used for temporary locations, that 301 is preferred by search engines, etc. etc. However, from my own experience, it is most effective to use both.
Let’s say you have gotten a new domain name or URL.
First, submit this to Google’s index, but make sure that you retain your old domain (or URL) for the time being.
Then, put a 302 on your old domain name. That way, your old domain name and its rankings in Google are retained. Additionally, whenever someone clicks on a link which still has your old domain, because your server has a 302, it will automatically redirect them to your new domain name.
Wait a few months for your new domain name to “age” in Google. Aging is very important, and it usually takes 2 to 6 months, at the very least.
When your new site has aged satisfactorily, change your 302 redirects to a 301. This will transfer the page ranking of your old site to your new one in Google.
How to make the redirection
The most robust way of doing the redirection is thru .htaccess.
- Create a text file called .htaccess in your local PC.
- Put the following in this text file:
Redirect 302 / http://www.newdomain.com/
Replace www.newdomain.com with your new domain name.
- Save your text file.
- Upload this file in your old domain name’s public_html.
If you only want to redirect users to another directory, try this more convenient method thru PHP:
- Create a file with the same filename as your old web page file (index.php, default.php, etc.)
- Enter the following lines:
header("Status: 301 Found");
- Upload this file in your directory.