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


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.





Related Posts

Project “Flash Page Redirect” - Posted @ 7:36 pm on February 8th, 2008
Display Simplepie RSS Feed In Reverse Order - Posted @ 11:45 pm on February 28th, 2010
Create Twitter RSS Of Your Tweets Based On Keywords - Posted @ 12:53 pm on October 23rd, 2009


Recommended



Comments

1. extremesh @ 07:10 pm on August 5th, 2009

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


Leave a comment:

Your comment :

 
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.



Blog Menu



Recent Friends



 

page made and maintained by mesh