Hi. I'm currently trying to set up a WAMP-install with subdomains which will fetch the files from the main domain, except for the config-file, which will differ among the subdomains. Something like: www.example.com -> loads fine, everything works, default config test.example.com -> loads the same files as above, except it loads its own config I've got the subdomain working (except I had to remove my .htaccess from the main domain, but I'll get around to fixing that later), but I'm wondering if I can do anything to make everything work on the Apache side, or if I need to fix the code running on the main domain to cater for subdomains. Any suggestions would be appreciated
No. The site has a config.php which will be different for each user (different credentials, different DB etc) - so it would be simpler to just have a main set of files, and then subdomains / subfolders for each separate entity using the system. While I understand that I need to modify some of the code to allow for the files to work as intended, I was just wondering if there was a way to let Apache believe that the files should be served from the main root folder, instead of the current subdomain.
You may include different configs like this /* Configs directory structure --------------------------- /configs/config.php - default config /configs/webmail/config.php - config for "webmail" subdomain ... */ $legitSubdomains = array('webmail','store','blog','developer'); $configsRootPath = '/configs/'; if(preg_match('#^(?:([^\.]+)\.)?yourdomain\.com$#', $_SERVER['HTTP_HOST'], $res)) { $subdomain = strtolower($res[1]); if(in_array($subdomain, $legitSubdomains)) { $configsRootPath.= $subdomain . '/'; } } require($configsRootPath . 'config.php'); PHP:
Thanks. I got it working, now I just need to adjust a few parameters so uploaded files and such are kept together with the subdomain-folders.