[英]Can CodeIgniter route to different controllers based on port number?
I would like to have CodeIgniter route to a different controller based on port number like so: 我想让CodeIgniter根据端口号路由到其他控制器,如下所示:
host_name/ControllerName => foo()
host_name:3000/ControllerName => bar()
I've added port 3000 to Apache's httpd.conf, so the server listens to both, but how do you tell CodeIgniter to route to a different method based on the port number? 我已将端口3000添加到Apache的httpd.conf中,因此服务器将侦听这两者,但是如何告诉CodeIgniter根据端口号路由到其他方法? I was thinking that something like
我当时在想
$route[":3000/test/index"] = "ControllerName/bar"
would work, but no. 会工作,但不会。
I've searched StackOverflow as well as the official documentation , but no luck. 我已经搜索了StackOverflow和官方文档 ,但是没有运气。
Anyone have an idea, or is port-based routing just not supported by the framework? 任何人都有想法,还是框架不支持基于端口的路由?
使用$_SERVER['SERVER_PORT']
获取端口号,然后在route.php中编写条件路由
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.