1

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?

Luke Willis
  • 8,429
  • 4
  • 46
  • 79
Eugene
  • 319
  • 2
  • 13
  • Improved formatting for easier readability. Fixed minor spelling issue. Shortened title and body where possible in order to improve reader engagement. – Luke Willis Jun 25 '15 at 19:42

1 Answers1

1

use $_SERVER['SERVER_PORT'] to get port number and then write conditional routing in route.php

Luke Willis
  • 8,429
  • 4
  • 46
  • 79
shankar kumar
  • 648
  • 5
  • 9