CodeIgniter 可以根据端口号路由到不同的控制器吗?

Can CodeIgniter route to different controllers based on port number?

我想让 CodeIgniter 根据端口号路由到不同的控制器,如下所示:

host_name/ControllerName      => foo() 
host_name:3000/ControllerName => bar()

我已经将端口 3000 添加到 Apache 的 httpd.conf,因此服务器会同时监听两者,但是您如何告诉 CodeIgniter 根据端口号路由到不同的方法?我在想

$route[":3000/test/index"] = "ControllerName/bar"

可以,但不行。

我搜索了 Whosebug 以及 the official documentation,但没有成功。

有人知道吗,或者框架不支持基于端口的路由?

使用$_SERVER['SERVER_PORT']获取端口号然后在route.php

中写入条件路由