1

一贯如此笨,假设我有$route['default_controller'] = "welcome";,如果我要求左侧的网址,我使用右侧列出的控制器:Codeigniter - “foo”子域可以自动使用“foo”文件夹中的控制器吗?

www.foo.com/   => applications/controllers/welcome.php with method "index" 
www.foo.com/bar  => applications/controllers/bar.php with method "index" 
www.foo.com/bar/baz => applications/controllers/bar.php with method "baz" 

这一切如预期。但是,当使用子域名,我想有一个子目录笨使用控制器,它具有相同的名称作为子域:

abc.foo.com/   => app/controllers/abc/welcome.php with method "index" 
abc.foo.com/baz  => app/controllers/abc/baz.php with method "index" 
abc.foo.com/baz/qux => app/controllers/abc/baz.php with method "qux" 

可以这样用路线呢?如果是这样,你如何设置基于子域的路线?

还是有更简单的方法来做到这一点?

回答

1

您可以为您在routes.php文件文件子域,如:

if (strstr($_SERVER['HTTP_HOST'], 'abc.foo.com')) { 
    $route['uri'] = "abc/controller/method"; 
} 
0

是的,它是可能的,

$route['the/path'] = "folder/controller/method";

相关问题