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
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.

Link to comment
Share on other sites

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~

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.