0

I'm working with Codeigniter and i want to have a URL like this:

admin.domain.com

And then route it to the real controller and function.

It means I don't want to have a URL like this : www.domain.com/admin.

I have one controller for back-end and another for front.

This is my default controller in route file:

  $route['default_controller'] = "home";

so how should i do it? with route file or htaccess file or some another way?!

lighter
  • 2,808
  • 3
  • 40
  • 59
Bahrami-Reza
  • 608
  • 2
  • 7
  • 24
  • 1
    I think the answer you look for is here: http://stackoverflow.com/questions/19513222/subdomains-leading-to-codeigniter-controllers/22051000#22051000 – Federico J. Apr 22 '14 at 06:46
  • i put this code in route file but didnt work in my case: switch ( $_SERVER['HTTP_HOST'] ) { case 'students.mysite.com': $route['default_controller'] = "students"; break; case 'teachers.mysite.com': $route['default_controller'] = "teachers"; default: // The list of your $routes lines at is was... break; } – Bahrami-Reza Apr 22 '14 at 07:10
  • im testing on localhost and change it to this: switch ( $_SERVER['HTTP_HOST'] ) { case 'admin.mysite/': $route['default_controller'] = "backend"; break; case 'mysite/': $route['default_controller'] = "home"; $route['404_override'] = ''; break; } – Bahrami-Reza Apr 22 '14 at 07:13
  • Possible duplicate of [Subdomains leading to Codeigniter Controllers?](http://stackoverflow.com/questions/19513222/subdomains-leading-to-codeigniter-controllers) – Federico J. Feb 03 '17 at 07:46

0 Answers0