Redirecting URL – Different ways

What?
Say, you have purchased an some domain sampl.com, sample.net and sample.org and you want to forward them all to sample.com, or directing from sample.com to www.sample.com, or from one location to a different location like www.sample.com/oldpath/ to www.sample.com/newpath/

How?
There are different methods to do, the following are some of them:

1. Using .htaccess

The syntax is:

redirect accessed-file URL-to-go-to

There are 3 parts;
(1) The Redirect command,
(2) The location of the file/directory you want redirected, and
(3) The full URL of the location you want that request sent to.

These parts are separated by a single space and should be on one line.
For example, if you want to redirect users from oldfile.html in the www directory of your account, myaccount, to newpage.html, the syntax should be

redirect /~myaccount/oldfile.html http://www.indiana.edu/~myaccount/newpage.html
Anyone going to http://www.indiana.edu/~myaccount/oldfile.html will end up on http://www.indiana.edu/~myaccount/newpage.html.
You must use a full URL even if you're going to send the users to another page on your own site.
You can also redirect an entire directory:
redirect /~myaccount/old_dir/ http://www.indiana.edu/~myaccount/new_dir/
Anyone going to http://www.indiana.edu/~myaccount/old_dir/filename.html will end up on http://www.indiana.edu/~myaccount/new_dir/filename.html.

2. Meta Refresh URL Redirect

Meta Refresh URL Redirect is an example of a meta refresh URL redirect. The code is quite simple.

<meta http-equiv="refresh" content="8;url=http://www.somecompany.com/index.html" />

Meta tag refresh is known to not be very search engine friendly and is consider spammy because of its misuse. If you keep it up around 8 seconds it is said it is ok. This method displays the new page that the refresh points to.

3. PHP URL Redirect

PHP URL Redirect is just like it says. The code for this script is short and simple. The following code goes at the top of the page.

<?php
header("location:http://www.somecompany.com/index.html");
exit;
?>

This script shows the new page that the refresh points to.

4. Javascrip URL Redirect

Javascript URL Redirect shows this script in action. Again this solution only takes one line of code.

<script type="text/javascript">document.location.href='www.somecompany.com/index.html'</script>

This code also sends you to the redirected url.

5. shtml URL Redirect

shtml URL Redirect displays the same code but don’t redirect you to the page like the other processes.

<!--#include virtual="http://www.somecompany.com/index.html"-->

Demos

www.skilliantech.com is redirected to www.skilliantech.co.uk

www.vajraproperties.in is redirected to www.vajraproperties.net

Tags: , ,

One Response to “Redirecting URL – Different ways”

  1. Cloak Url says:

    Enter website URL to check whether a redirect link Search Engine Friendly. Cloak Url

Leave a Reply