有一个简单的方法来创建于codeigniter子域? [英] Is there an easy way to create subdomains on codeigniter?
问题描述
有一个简单的方法来创建于codeigniter子域像api.site.com?
Is there an easy way to create subdomains on codeigniter like api.site.com?
推荐答案
你采用的方法取决于不同的子域是从主站点。如果它们是非常相似,并且将使用相同的codeBase的:
The approach you take depends on how different the subdomain is from the main site. If they are very similar and will be using the same codebase:
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/';
如果你需要一些设置,以在不同的子域不同,你可以创建像这样一个配置文件:
If you need some settings to be different on a different subdomain, you could create a config file like so:
switch($_SERVER['HTTP_HOST']){
case 'www.example.com':
// settings specific to www subdomain
$config['foo'] = 'bar';
break;
case 'apl.example.com':
// settings specific to apl subdomain
$config['foo'] = 'baz';
break;
}
另外,也包括建立子域一个单独的应用程序文件夹,但指向同一个系统文件夹。如果你组织你的文件系统是这样的:
Another approach would include setting up a separate application folder for the subdomain, but pointing at the same system folder. If you organize your filesystem like this:
example.com
common
system
application
www
htdocs
application
apl
htdocs
application
您可以再点index.php文件中的每个在公共/ system目录htdocs文件。你也可以把code要在普通/应用程序中所有子域之间共享,包括他们的code。
You could then point the index.php file in each htdocs folder at the common/system directory. You could also put code you want to share between all subdomains in common/application and include them from your code.
这篇关于有一个简单的方法来创建于codeigniter子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!