One content folder for multiple subdomains

Using a single web hosting account to host multiple sites

One content folder for multiple subdomains

Postby ShuGos » Wed Sep 19, 2007 6:47 am

Hi,

I have installed a Moodle package. I want to server one package on multiple subdomains. Every subdomain has his onw config file.

/home/domain.com/subdomain1/
/home/domain.com/subdomain2/

al get it's content files from
/home/domain.com/moodle_package/

But the config file is per domain different.
What i want to create is. When there is a Moodle update, i only have to update it on one location. And it saves diskspace.

Can i accomplish this with mod_rewrite?
ShuGos
 
Posts: 2
Joined: Wed Sep 19, 2007 6:29 am

Postby richardk » Wed Sep 19, 2007 12:17 pm

Can i accomplish this with mod_rewrite?

Mod_rewrite can't rewrite up directories above the document root (eg. from /home/domain.com/subdomain2/ to /home/domain.com/moodle_package/).

You could use Symbolic Links instead of directories and make the configuration file conditional, eg.
Code: Select all
<?php

// Get the sub domain name.
if(strpos(getenv('HTTP_HOST'), 'www.') === 0)
{
  $multi_sub_name = substr(getenv('HTTP_HOST'), 4);
}
else
{
  $multi_sub_name = getenv('HTTP_HOST');
}

$multi_sub_name = explode('.', $multi_sub_name);
$multi_sub_name = $multi_sub_name[0];

// Configuration based on sub domain name.
switch($multi_sub_name)
{
  case 'sub_domain_name_one':
    // the configuration of sub_domain_name_one.domin.com
    break;
  case 'sub_domain_name_two':
    // the configuration of sub_domain_name_two.domin.com
    break;
}
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ShuGos » Wed Sep 19, 2007 11:09 pm

Ok, thanks. I will give it a try.
ShuGos
 
Posts: 2
Joined: Wed Sep 19, 2007 6:29 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 3 guests

cron