Connecting Tech Pros Worldwide Help | Site Map

Redirect Based on What They Typed In

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 12:31 AM
Google Mike
Guest
 
Posts: n/a
Default Redirect Based on What They Typed In

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!

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.