Hide Codeigniter controller name from URL with same routes

i'm just getting started at codeigniter, i want to hide controller name from URL with same routes setup.

i have 3 controllers which are students, staff, teachers having same function called home, this won't work obviously

$route['home'] = 'students/home'; $route['home'] = 'staff/home';

is there any way to accomplish this? i have session data using codeigniter session class containing user type so i tried something like this

session_start() $route['home'] = $_SESSION['user_type'].'/home';

but i cant get the session data, maybe its using codeigniter session class?? so, how can i get the data? or is there other solution?


Perhaps you should write a common controller and disperse by your second URI parameter:

home/students or home/staff

$route['home/:any'] = "home";

and home controller's index method:

public function index() { $type = $this->uri->segment(2); switch($type){ case "student": $this->student(); break; case "staff": $this->staff(); break; default: $this->some_other_method(); break; } }

Obviously you would create a student and staff method and handle things differently if need be.

A side note - why do you want to conceal the controller's name? It's not like that's a security hole or anything.


  • Converting nested select into join
  • work on manual query but not work at bash sh file
  • Conditional IO action
  • Primary key with ASC or DESC ordering?
  • Mqsql Email $link Message
  • Binding functions with multiple arguments results in C2027
  • Loading role-based navigation upon login
  • Hide Codeigniter controller name from URL with same routes
  • Docker compose mysql connection failing
  • Casting a type (interface) via map to observable
  • Giving uploaded images a unique name for mysqli
  • What is supported by broadcasting in tensorflow? How dimensions matches determined?
  • Django ORM Left Join With GROUP BY and SUM
  • show popover on input validation in angularjs
  • How to merge two Request in Laravel
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • How can I extend PHP DOMElement?
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • Can my PDF ping my server when it is opened?
  • Laravel 4 routing not working due to .htaccess file?
  • Iron Router: How do I send data to the layout?
  • Can I have a variable number of URI parameters or key-value pairs in Laravel 4?
  • Two Tables Serving as one Model in Rails
  • Approximate Order-Preserving Huffman Code
  • How can I extract results of aggregate queries in slick?
  • Android full screen on only one activity?
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Accessing IRQ description array within a module and displaying action names
  • R: gsub and capture
  • SVN: Merging two branches together
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • trying to dynamically update Highchart column chart but series undefined
  • embed rChart in Markdown
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app
  • How to load view controller without button in storyboard?