I want to first thank some of you guys for the help lately. It is much appreciated.
Now I have to move on to a new step. I have 2 sites that both load a header.inc.php. In both cases these files are the top of the page with images and navigation. I believe these are called as include statements on both sites.
I have mydomain.com pointed there as well as sub.otherdomain.com
I want to modify the scripts to look for for the HTTP _HOST and if the host is sub.otherdomain.com, a different header.inc.php will be loaded such as XXheader.inc.php.
Of course is the host is www.mydomain or mydomain.com (or any other domain for that matter), I need to load the default header.inc.php
I have looked at several code samples and found them quite confusing. Sample code appreciated, and always helps with some explanation.
thanks for any help in advance
include header.inc.php based on HTTP_HOST
Moderator: General Moderators
Re: include header.inc.php based on HTTP_HOST
Code: Select all
if ($_SERVER['HTTP_HOST']=='foo.domain.com')
{
include('fooheader.inc.php');
}
elseif ($_SERVER['HTTP_HOST']=='bar.domain.com')
{
include('barheader.inc.php');
}
else // use generic header.inc.php for any other (or no) subdomain
{
include('header.inc.php');
}Re: include header.inc.php based on HTTP_HOST
Seems to work beautifully!
Now I should also modify it for the correct favicon per domain!
Thanks
Now I should also modify it for the correct favicon per domain!
Thanks
Re: include header.inc.php based on HTTP_HOST
Apollo,
I used this code now in 2 different scripts, as well as a modified version to take care of a link problem as well with one of those scripts. Thank you so much! Today's lesson was more useful than I had imagined!
Still can not get it to work on my favicon issue however. I may be stuck with that for a while
I used this code now in 2 different scripts, as well as a modified version to take care of a link problem as well with one of those scripts. Thank you so much! Today's lesson was more useful than I had imagined!
Still can not get it to work on my favicon issue however. I may be stuck with that for a while