简体   繁体   中英

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:

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? 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.

Anyone have an idea, or is port-based routing just not supported by the framework?

使用$_SERVER['SERVER_PORT']获取端口号,然后在route.php中编写条件路由

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM