Connecting Tech Pros Worldwide Help | Site Map

Redirect Based on What They Typed In

  #1  
Old July 17th, 2005, 01:31 AM
Google Mike
Guest
 
Posts: n/a
Imagine your web hosting provider just permitted you to type
*.mydomain.com and you still get to the mydomain.com website that they
host for you. Imagine you want to setup websites for your family like
dad.mydomain.com, mom.mydomain.com, etc.

Well, this is a request and some information for you. First, here's
how you could use PHP to react to what they type in the URL:

<!-- save as index.php in /var/www/html on Linux Apache: -->
<?php
$headers = getallheaders();
if (in_array('dad.mydomain.com', $headers)) {
header('Location: http://www.mydomain.com/dad/');
exit;
}
if (in_array('mom.mydomain.com', $headers)) {
header('Location: http://www.mydomain.com/mom/');
exit;
}
?>

So imagine your workstation is where you're developing and testing
this. What changes would you make to /etc/hosts, Apache, or something
else on your Linux system so that it accepts *.mydomain.com?

So, the request -- the reason I ask is I want to inform my web hosting
provider of the changes they can make to their Linux system so that I
can start using this PHP index.php script to redirect to various
websites under mydomain.com.

For now, in experiment mode, I had to add dad.mydomain.com and
mom.mydomain.com to /etc/hosts for 127.0.0.1 to get this to work. But
I wish I could do something dynamically.

Thanks!
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirect based on request. THG answers 1 December 16th, 2007 01:18 PM
Creating a strongly typed object from a basic serialized class Simon Hart answers 3 November 7th, 2006 03:45 PM
dynamically adding controls, saving, viewing change on page?? Greg answers 1 November 18th, 2005 09:27 AM
dynamically adding controls, saving, viewing change on page?? Greg answers 1 November 18th, 2005 08:34 AM