Jump to content

Template based on domain name


RavenStar

Recommended Posts

I have several domains all parked on top of the main one, and I want the template of the site to be determined on which domain they go to.

So if they goto www.site1.com it shows template A and if they goto site2.com it shows template B and so on.

 

Here is what I have so far, which isn't working;

$url = $_SERVER['HTTP_HOST'];

if (strpos($url,"siteA.")) {
$template = 1;
$title = "Welcome to SiteA";

} else if (strpos($url,"siteB.")) {
$template = 2;
$title = "Welcome to SiteB~~";
}

..and so on, it goes for awhile.

 

I know I should probably have the $template and $title in an array, but I don't know how to go about doing that.

 

How can I achieve what I am trying to do?

 

Thanks~

Link to comment
https://forums.phpfreaks.com/topic/95204-template-based-on-domain-name/
Share on other sites

Set up a database with template name and all that in there, then when someone goes to site1.com, store that as a $_SESSION variable. You could also set up a directory tree and pass all the css and stuff off the DB before creating the HTML, thus the ability to host multiple sites on one server/account.

Thanks for the reply.

I have thought about storing it in a database but decided against it for a few reasons.

 

The reason I'm trying to do it the way I am, is so I can just have one copy of the core files under one account instead of having an account for each domain.

 

In my example above, I am not sure if I'm using strpos correctly as it isn't working.

Could some assist me in working out my above code to make it function?

 

Thanks~

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.