PCのテスト環境で、ドメインが以下のように複数あり、それぞれAPIもある場合、
www-test1.●●●.net ⇒ api-test1.●●●.net に向かせたい
www-test2.●●●.net ⇒ api-test2.●●●.net に向かせたい
www-test3.●●●.net ⇒ api-test3.●●●.net に向かせたい
CodeIgniterでは、
application/config/development/配下に
application_env.php
といファイルがあり、
そこで、以下のような記述で設定が可能です。
$pattern ='/test[1-9]?/';
$match = array();
preg_match($pattern,$_SERVER["HTTP_HOST"],$match);
$test = $match[0];
$config['api_url'] = 'https://api-'.$test.'.●●●.net';
$config['pc_url'] = 'https://www-'.$test.'.●●●.net';
$config['sp_url'] = 'https://sp-'.$test.'.●●●.net';
設定例やURLは仮です。