0

i have two sub-domains pointing at the same file.the sub-domain's are test.test.com and fail.test.com and the file is index.php. Now i want to be able to work with both of those domains within the same file so i used this code:

if($_SERVER['HTTP_HOST']=='test'){
	echo"test";
}else if($_SERVER['HTTP_HOST']=='fail'){
echo"fail";
}

but it will not work. can anybody help? thanks in advanced

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by tcollins412
0

I don't understand how you have this configured. Normally sub-domains are entirely separate and don't share the same code. You could have parked domains pointing to another domain and then they would all be treated the same and share the same code but that is entirely different. In that case, you can check which domain name was used in the (common) code.

Please clarify.

0

@chrishea
I have a development server where projects get subdomains configured as virtual hosts all other unmatched subdomains resolve to a single catch-all vhost. I don't think it is terribly uncommon just depends on the usage.

@tcollins
If you call <?php phpinfo(); ?> from that file and look though the results for HTTP_HOST and it's value, you will probably see that the HTTP_HOST is test.domain.com or fail.domain.com, not just the subdomain portion.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.