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.co m, mom.mydomain.co m, 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('Locatio n: http://www.mydomain.co m/dad/');
exit;
}
if (in_array('mom. mydomain.com', $headers)) {
header('Locatio n: http://www.mydomain.co m/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.co m and
mom.mydomain.co m to /etc/hosts for 127.0.0.1 to get this to work. But
I wish I could do something dynamically.
Thanks!
*.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.co m, mom.mydomain.co m, 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('Locatio n: http://www.mydomain.co m/dad/');
exit;
}
if (in_array('mom. mydomain.com', $headers)) {
header('Locatio n: http://www.mydomain.co m/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.co m and
mom.mydomain.co m to /etc/hosts for 127.0.0.1 to get this to work. But
I wish I could do something dynamically.
Thanks!