Vee*_*Bee 6 php subdomain codeigniter wildcard
基本上我正在尝试使用本地化子域创建一个codeigniter应用程序,如果我访问:
ca.site.com - >它将运行相同的系统但显示加拿大内容.us.site.com - >仍然运行相同的系统,但显示美国内容.
加上如果我访问www.site.com,它将使用ip2country自动获得正确的本地化,并将被重定向,如果从英国,redir到uk.site.com
只有1个系统文件夹和1个应用程序文件夹:
root/system/application index.php
现在我希望网址能够从他们所在的本地化中保留.喜欢:
uk.site.com/profile/1将访问配置文件控制器ca.site.com/profile/3也将访问uk.site.com使用的同一控制器
我将如何实现这一目标?
请原谅我,如果我的询问有点粗糙.但我希望有人可以帮助我.
可能有很多方法可以做到这一点......但我能立即想到的一种方法是将一些内容放入index.php 文件中,其中建立了预加载的自定义配置值,可以执行类似的操作。 ..
/*
* -------------------------------------------------------------------
* CUSTOM CONFIG VALUES
* -------------------------------------------------------------------
*
* The $assign_to_config array below will be passed dynamically to the
* config class when initialized. This allows you to set custom config
* items or override any default config values found in the config.php file.
* This can be handy as it permits you to share one application between
* multiple front controller files, with each file containing different
* config values.
*
* Un-comment the $assign_to_config array below to use this feature
*
*/
$region_prefix_var = explode('.', $_SERVER['HTTP_HOST']);
$assign_to_config['region_prefix'] = $region_prefix_var[0];
Run Code Online (Sandbox Code Playgroud)
然后在你的 config.php 文件中
global $region_prefix_var;
$config['base_url'] = $region_prefix_var[0].".site.com/";
Run Code Online (Sandbox Code Playgroud)
...或者您可以根据 $_SERVER['HTTP_HOST'] 值覆盖 $assign_to_config 数组中index.php 文件中的base_url。然后在任何其他控制器或任何你可以基于的东西
$this->config->item('region_prefix');
Run Code Online (Sandbox Code Playgroud)
然后只需将所有子域指向同一目录并在您的应用程序中进行本地化即可。
| 归档时间: |
|
| 查看次数: |
2073 次 |
| 最近记录: |