Selective Hostname Redirections

April 12, 2008

Some of the web hosting do provides domain aliases service such as Exabytes Network. It will be kinda waste if the aliased domain showing the same output as the parent domain.

When having aliased domain sharing the same default page, some work need to be done if you want specific domain to be redirected to other location or path such as :

http://www.oldcoconut.com/ => http://www.yahoo.com/

OR

http://www.oldcoconut.com/ => http://www.oldcoconut.com/any_folder_or_filename

If you are good in php or even with a novice php skill, with some hint from the php manuals, you still can start coding the selective redirection.

Simple selective redirection using php script will involve two component, server variables and header() function. The server variable involved will be SERVER_NAME.

Sample script of selective redirection are as below:

$myHostname = “oldcoconut.com”;
$myHostRedirect = “http://oldcoconut.com/sample“;
if($myHostname==$_SERVER[’SERVER_NAME’])
{
  header(”Location: “.$myHostRedirect);
}

If you do have multiples aliased domain which you wish to have them redirected to other location or folder, you may consider on using arrays to keep the domain and its redirection URL.

If you still want to preserve the domain name on the URI Address, you may consider on using frame to hide the redirected url.

You may refer to the below sample script for further references:

selective_hostname_redirection.zip

One Response to “Selective Hostname Redirections”

  1. DALE Says:


    Pillspot.org. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. Online Pharmacy. Buy pills online

    Buy:Amoxicillin.Aricept.Buspar.Wellbutrin SR.Ventolin.SleepWell.Lasix.Zetia.Female Cialis.Nymphomax.Acomplia.Advair.Benicar.Lipothin.Zocor.Lipitor.Seroquel.Cozaar.Female Pink Viagra.Prozac….

Leave a Reply