URL redirection can be used for many purposes. Maybe you have just moved the content of a webpage to another webpage or domain and you want to redirect the frequent visitors of your website to the new webpage automatically. The knowledge of technique of redirecting URL is also useful if you want to shorten a long affiliate URL.
Below are several ways you can use to redirect visitors to any URL you want:
- Using Meta Tag
The tag for doing it is:
META http-equiv = "refresh" content = "0; URL = anydomain.com/destination.html"
Just put the tag above between the HEAD and /HEAD tags in a webpage. That way, when someone visits the webpage that contains the tag, he will be redirected to destination.html automatically. Don't forget to include the "http" protocol which has been omitted.
In order to find out how many visitors have been redirected you may try to replace the destination URL with a tracking URL.
- Using PHP code
In PHP, "Header" is a built-in function that is often used to accomplish this task. This function can be used to redirect visitors depending on a specific condition. For instance, you can use this function to redirect someone to a webpage after submitting his correct username and password.
Here is the code:
header("Location: anydomain.com/destination.php");
where destination.php is the destination URL.
Keep in mind that you have to save the file with .php extension in order to make it works.
- Using the redirect URL facility from your hosting service
Many web hosting services provide a facility that you can use to redirect pages of your site to any url you want. This way, you only have to fill the source and the destination URL in a blank form and hit the submit button.
- .htaccess
You can also use your .htaccess file for this purpose as long as the hosting company you are using allows you to access this file. The code below will redirect visitors from oldpage.html to newpage.html.
Redirect /directory/oldpage.html anydomain.com/directory/newpage.html
Just put the code in your .htaccess file.
Now, how if you want to display a URL without using .html or .php extension? First, put the Meta Tag or the PHP code above in a file and name it as index.html or index.php. Then create a subdomain and upload the file into it. When someone visits the subdomain, he will be redirected to the destination URL.
There are actually other techniques of redirecting URL with different advantages and disadvantages. For instance, with Domain Forwarding you can forward your domain name to a URL. Domain Masking that looks similar with Domain Forwarding can hide a URL with your own domain name so the real URL will not be displayed in the address bar of your visitor's browser.
Whatever technique of url redirect you intend to use, always choose the one that would best fit your needs.
About The Author:
Heris Yunora is the owner of
http://www.unlimitedhostingplan.com, a website that contains information on shared hosting plan with unlimited database and other useful features.