There are many reasons why you may want to use some form of redirection on your websites. You may want to prevent someone from browsing certain folders on your site, you have moved a page or site to another location, or you may want to mask or shrink a long affiliate link.

One of the simplest methods of doing this is to create a short script, less than 10 lines, in either html or php. Lets say you want to stop people from browsing your images folder and you want to redirect them back to your home page if they try.

The quickest way would be to create an index.php in your images folder with the following code:

Alternatively you could do the same thing with html. Simply create and index.html in the folder with the following code

Both of these will immediately redirect the user back to your home page if they try to browse the folder.

If you have moved a page or website then you will want to use 301 redirect. This tells search engines that the page has been permanently moved and they should transfer and page rank the old page had to the new page. I don’t think this can be accomplished with an html page but it can be done simply with php. Simply create a page with the old page name that contains the following:

For example if you had a page called compostmaker.php and then moved it to howtomakecompost.php you would create compostmaker.php containing the above code replacing you-page.php with howtomakecompost.php.

For masking or shrinking affiliate urls you can again use both html or php. The best way to do this is to create a folder on your website to hold all the redirection files. Name this folder something like recommends, goto, visit, likes or info_on and then name the files after the company you are promoting.

Let’s say you want to promote a company called ‘Great Ducks‘ and have an affiliate url something like this:

http://www.greatducks.com/affiliates/index.php?id=78897654

That url looks fairly ugly and is obviously an affiliate link, you could use a company like tiny url to shrink it, but a lot of people are suspicious of these urls as they used so often for affiliate marketing. By creating a folder on your site and creating a short redirection script you can create a url like the following:

http://www.your-site.com/info_on/GreatDucks.php

For this we would create a folder called ‘info_on‘ on your website and then create a file inside this folder called GreatDucks.php that contains the following:

This will immediately redirect the user to the Great Ducks affiliate site. You may however want to relay a message to the user before relaying them to the affiliate site. This isn’t possible with php, however it is with html. To do this with html create a file called GreatDucks.htm in the info_on folder with the following code:

This will display the message ‘ You will be redirected to the Great Ducks page in 20 Seconds‘. Obviously you would want to put something a little more interesting here, maybe a special offer further information. You can put anything you like between the body tags.

The important bit is the

between the head tags. The value 20 is the amount of seconds before the page redirects, 0 will redirect immediately. The URL is the destination page that the user will be redirected to.

This is a very simple and quick method of redirecting people to where you want them to go and is idle from preventing people from snooping around your site, and browsing folders you would rather they didn’t visit. In future posts I’ll explore more complex redirection scripts.This is a very simple and quick method of redirecting people to where you want them to go and is idle from preventing people from snooping around your site, and browsing folders you would rather they didn’t visit. In future posts I’ll explore more complex redirection scripts.