Redirect Page Based On Domain Names
Posted at 7:10 pm on August 5th, 2009 in Tips & Tricks Hits: 692

This is a really quick script for those who have one hosting with multiple domains pointing to it and would like to redirect the domains to different location instead of the relative path or home directory.

<?php
// ----- extremesh -----
// ----- ramesh.ws -----
// Parked Domain Redirect Script

// get's the entered domain name
$domain = $_SERVER['HTTP_HOST'];

// part which checks what url was typed by user and redirect
// to the domain accordingly.
// here you can set 2 domains, add by using elseif statement
// replace domain1, domain2 and etc as needed
if ($domain == "domain1.com" || $domain == "www.domain1.com") {
 header("Location: http://urlfordomain1.com");
} elseif ($domain == "domain2.com" || $domain == "www.domain2.com") {
 header("Location: http://urlfordomain2.com");
} else {
 echo "The site you are looking for can't be found!";
}

?>

To add more domains just append the ELSEIF statement in the script. I am actually using this script with my hosting and the parked domain service.


|

  • http://www.reddit.com/user/extremesh extremesh

    This is a really quick script for those who have one hosting with multiple domains pointing to it and would like to redirect the domains to different location instead of the relative path or home directory.

    This comment was originally posted on Reddit

  • http://www.bing.com/ Carajean

    Ppl like you get all the brains. I just get to say tashnk for he answer.

 
About Me

I'm ramesh from Perak, Malaysia. Blogging is my hobby hence this blog is my second home to share my life, interests and etc. One can always interact with me by using the mediums below.



Blog Menu

» Main Page
» Blogging ( 137 | rss )
» Info Tech ( 43 | rss )
» Mesh Views ( 3 | rss )
» My Mesh ( 17 | rss )
» My Poems ( 6 | rss )
» My Workshop ( 16 | rss )
» myIndians-World ( 45 | rss )
» Places & Events ( 62 | rss )
» Shoot Me ( 17 | rss )
» Tips & Tricks ( 21 | rss )
» Contact Me


Micro Mesh



Get Updates



 

page made and maintained by mesh