By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,641 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,641 IT Pros & Developers. It's quick & easy.

Redirect Based on What They Typed In

P: 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!
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.