I am creating a booking engine . Same code will be used on two different domain BUT there should be an identifier to tell which domain will be using which code . Say in database I Identify AAA.COM should use code instance A and BBB.COM should use code instance B .
Both the domains are on same server .
Can anyone suggest how do I do that via apache or any tips to accomplish which I am looking for .
Well, php does have access to the HOST header being part of the request. Just use $_SERVER['SERVER_NAME']
or $_SERVER['HTTP_HOST']
. Check the documentation for the difference: http://php.net/manual/en/reserved.variables.server.php
Using that you can create a condition inside your php scripts:
<?php
// ...
switch ($_SERVER['SERVER_NAME']) {
case 'aaa.com':
// use database A
break;
case 'bbb.com':
// use database B
break;
default:
throw new Exception('undefined host at runtime');
}
// ...