Multiple Sites for One Installation

Multiple Sites for One Installation

Postby admin » Tue May 11, 2010 9:48 am

Affiliate Niche Script can be setup with one set of installation files to serve an unlimited number of sites/domains.

To accomplish this your host must support the use of domain aliases and your main site where your files are installed must be setup on a full domain name, not a sub domain.

Step 1:

Log in to your hosting control panel for your site and create some domain aliases to point to your first site. For example my main site is www.widgets.com and I setup www.blue-widgets.com and www.red-widgets.com as domain aliases.

Step 2:

Verify your domain alias works by visiting your alias domain. In our example if you visit www.red-widgets.com you should see the site contents of www.widgets.com

Step 3:

Replace the contents of your config.php file from the main site's ANS installation (/includes/config.php) with the code below:

Code: Select all
<?php

switch ($_SERVER["SERVER_NAME"]) {
   case 'www.blue-widgets.com':

      define("dbhost", 'localhost');
      define("dbuser", 'myuser');
      define("dbpass", 'mypass');
      define("dbname", 'bluewidget');
      define("dbprefix", 'ans_');
      break;
   case 'www.red-widgets.com':

      define("dbhost", 'localhost');
      define("dbuser", 'myuser');
      define("dbpass", 'mypass');
      define("dbname", ''redwidget);
      define("dbprefix", 'ans_');   
      break;
   case 'www.green-widgets.com':

      define("dbhost", 'localhost');
      define("dbuser", 'myuser');
      define("dbpass", 'mypass');
      define("dbname", 'greenwidget');
      define("dbprefix", 'ans_');   
      break;
   default:
      
      define("dbhost", 'localhost');
      define("dbuser", 'myuser');
      define("dbpass", 'mypass');
      define("dbname", 'widget');
      define("dbprefix", 'ans_');
}


Basically what this code does is checks the domain name of the page, if it matches any of the configured domains it will use a new database, if it does not match any of the domains it will use a default database which will be your main site.

To make things even simpler you could configure all the sites to share the same database by configuring each site use a different database prefix as below:

Code: Select all
<?php

define("dbhost", 'localhost');
define("dbuser", 'myuser');
define("dbpass", 'mypass');
define("dbname", 'widget');

switch ($_SERVER["SERVER_NAME"]) {
   case 'www.blue-widgets.com':

      define("dbprefix", 'blue_');
      break;
   case 'www.red-widgets.com':

      define("dbprefix", 'red_');   
      break;
   case 'www.green-widgets.com':

      define("dbprefix", 'green_');   
      break;
   default:
      
      define("dbprefix", 'ans_');
}


Step 4:

Upload your install folder and access each new site pointing to the install folder and install the site. Example http://www.blue-widgets.com/install/
This will install a new copy of ANS in your new database, completely seperate from the main site. If you use PhpMyAdmin or similar you could backup & restore your main database to the new databases manually to bypass the need to run the installer again.
User avatar
admin
Site Admin
 
Posts: 462
Joined: Sun Nov 22, 2009 7:24 pm

Re: Multiple Sites for One Installation

Postby twitch » Sat May 15, 2010 1:47 am

How will this work with the cache folder?
twitch

 
Posts: 254
Joined: Sat Feb 20, 2010 12:09 am

Re: Multiple Sites for One Installation

Postby admin » Mon May 24, 2010 8:21 am

twitch wrote:How will this work with the cache folder?


the cache folder will be shared between each site.
User avatar
admin
Site Admin
 
Posts: 462
Joined: Sun Nov 22, 2009 7:24 pm

Re: Multiple Sites for One Installation

Postby twitch » Sat Jun 19, 2010 6:32 am

any way for this to have each site load its own language file?
twitch

 
Posts: 254
Joined: Sat Feb 20, 2010 12:09 am

Re: Multiple Sites for One Installation

Postby admin » Wed Jun 30, 2010 12:30 pm

Hi,

Yes in theory you could copy the logic from the config.php and put it inside the language files like this:

Code: Select all
switch ($_SERVER["SERVER_NAME"]) {
   case 'www.blue-widgets.com':

      define("langHome", 'Home');
      break;
   case 'www.red-widgets.com':

      define("langHome", 'Home1');   
      break;
   case 'www.green-widgets.com':

      define("langHome", 'Home2');   
      break;
   default:
      define("langHome", 'Home3');   
}
User avatar
admin
Site Admin
 
Posts: 462
Joined: Sun Nov 22, 2009 7:24 pm

Re: Multiple Sites for One Installation

Postby twitch » Wed Jun 30, 2010 2:51 pm

Nice thanks also anyone willing to do this I have set up 6 stores off 1 install and let me tell you its soooooo much easier to maintain. You will need to add both the www and non www as 2 separate things or the site wont work correctly

Code: Select all
<?php

define("dbhost", 'localhost');
define("dbuser", 'myuser');
define("dbpass", 'mypass');
define("dbname", 'widget');

switch ($_SERVER["SERVER_NAME"]) {
   case 'www.blue-widgets.com':

      define("dbprefix", 'blue_');
      break;

     case 'blue-widgets.com':
     define("dbprefix", 'blue_');
      break;

     
   default:
     
      define("dbprefix", 'ans_');
}



so add both the www and non www for everything to work correctly.
twitch

 
Posts: 254
Joined: Sat Feb 20, 2010 12:09 am

Re: Multiple Sites for One Installation

Postby twitch » Thu Jul 01, 2010 6:48 pm

Ok so I ran into this problem after it was too late is there any way for the .htaccess file to allow different stores to have different .htm .php .html you get what im getting at here after setting up like this I forgot I set up all my stores a little different from each other to help with my footprint if not then I can just purge all the urls from google as I get very little traffic as is
twitch

 
Posts: 254
Joined: Sat Feb 20, 2010 12:09 am

Re: Multiple Sites for One Installation

Postby victorsmith » Mon Sep 26, 2011 11:53 am

Hello, A very insightful post. Thanks for the info. Its great that if our default settings are giving us messy or stringy builds, this dialog can probably help.Thanks for the information.
victorsmith

 
Posts: 1
Joined: Mon Sep 26, 2011 11:27 am



Next

Return to Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

cron