有没有办法将多个域路由到单个控制器/功能但具有不同的参数?
例如:
some_domain.com -> sites/display/site_slug_1
other_domain.com -> sites/display/site_slug_2
“sites”是控制器,“display”是功能。
是否可以将新域添加到routes.php文件中并将它们重定向到正确的uri?
无法回答我自己的问题,所以我在这里发布解决方案:
我最后在routes.php文件
中添加了这样的内容//define each domain and it's route
$sites_routes = array();
$sites_routes['domain1.com'] = 'sites/display/site_slug_1';
$sites_routes['domain2.com'] = 'sites/display/site_slug_2';
//get domain name
$host = $_SERVER['HTTP_HOST'];
preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
//define each domain and it's route
$sites_routes = array();
$sites_routes['domain1.com'] = 'sites/display/site_slug_1';
$sites_routes['domain2.com'] = 'sites/display/site_slug_2';
//get domain name
$host = $_SERVER['HTTP_HOST'];
preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
//build the routes
if(isset($sites_routes[$matches[0]]))
{
$route['default_controller'] = $sites_routes[$matches[0]];
$route['(:any)'] = $sites_routes[$matches[0]].'/$1';
}
else
{
$route['default_controller'] = 'home';
}
答案 0 :(得分:0)
您可以在不同的域上使用.htaccess进行映射
答案 1 :(得分:-1)
def __call__(self, string):
p = rinterface.parse(string)
res = self.eval(p)
return conversion.rpy2py(res)