mutliple domains on one site, unique content by domain name

Status
Not open for further replies.

mesam

New member
Feb 28, 2008
128
2
0
I have multiple domains pointing to one site. I'd like for unique content to load based upon the domain name.

For example, if the domain is hxxp://fish.com, ideally content would load related to fish. But if the next domain is hxxp://books.com then content related to books loads.

If that is not possible, is there a way to load dynamic random content every time someone visits one of the domains?

Is there any way to accomplish this by loading informational content, or through some sort of affiliate feed setup, and ideally without running a database?

Thanks,

mesam
 


Kinda busy to look up the exact details. But what you want to do is use an .htaccess file and utilize mod_rewrite to change the condition based on the host name.

For example when I was redirecting subdomains....

Code:
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_HOST} ^([^\.]+)\.thedomain\.com$ [NC]
RewriteRule ^.*$ /home/username/domain.com/offer.php?id=%1 [L]

Basically you would need to modify the {HTTP_HOST} line to grab the domain itself (^www\.([^\.]+)\.com$ [NC] if I got my regex correct), so that you can then pass the host name to the php file.

OR

You can use PHP and $_SERVER['HTTP_HOST']; to pull the host name, and load up data via PHP that way. (could probably use smarty template engine to change the theme based on host, and to change database configuration to pull from different tables for the new content).

It's just the mod rewrite method may be easier if you're also separating content and design by folder.
 
All right, thanks for the info. I can now see that this is well beyond my abilities. Anyone want to put this together for some $?
 
For the PHP part kblessinger mentioned above, you can simply use includes which you have duplicated off of one template and modified:

Code:
<?php
$host = $_SERVER['HTTP_HOST'];

switch $host {
  case 'domain1.com': include 'content1.php';
    break;
  case 'domain2.com': include 'content2.php';
    break;
  case 'domain3.com': include 'content3.php';
    break;

  //can add more cases

  default: include 'contentdefault.php';
}
?>
 
For the PHP part kblessinger mentioned above, you can simply use includes which you have duplicated off of one template and modified:

Code:
<?php
$host = $_SERVER['HTTP_HOST'];

switch $host {
  case 'domain1.com': include 'content1.php';
    break;
  case 'domain2.com': include 'content2.php';
    break;
  case 'domain3.com': include 'content3.php';
    break;

  //can add more cases

  default: include 'contentdefault.php';
}
?>


Yea, thats one way of doing it , mainly if you just want to change the content. But if you also want to change the look some, I recommend using the smarty template engine and just change the template folder based on domain.
 
Damn. Oh so that way you can swith it like affiliate links...Never thought of that. Here's a twist of lemon to go with.

Add a WP site (or CMS of your choice) make each domain a category and instead of "plain" includes you could pull the category / domain as needed on the fly. Store search terms into a database for future use and resort according to need (based on popularity), serve up the matching ads (of course) and then use those same search terms to go back and appropriate the top results from X, shuffle and then feed back into WP ala feedWP or some sort for a automated machine. You can go really niche with this.
 
For the PHP part kblessinger mentioned above, you can simply use includes which you have duplicated off of one template and modified:

Code:
<?php
$host = $_SERVER['HTTP_HOST'];

switch $host {
  case 'domain1.com': include 'content1.php';
    break;
  case 'domain2.com': include 'content2.php';
    break;
  case 'domain3.com': include 'content3.php';
    break;

  //can add more cases

  default: include 'contentdefault.php';
}
?>


Thats kind of how I do it, with SQL data base and smarty templates.

Really flexible and powerful way of delivering sites & content quickly from scratch

Code:
<?php
$host = $_SERVER['HTTP_HOST'];

switch $host {
  case 'domain1.com': 
    $siteid = 1;
    break;
  case 'domain2.com': 
   $siteid = 2;
    break;
  case 'domain3.com': 
  $siteid = 3;
    break;

  //can add more cases

  default: $siteid = 1;
}
?>
 
Status
Not open for further replies.