Very simple routes question about /admin style routes |
[eluser]clone45[/eluser]
Hello, I'm having some trouble setting up my routes for an admin section of a site. I'm very new to CodeIgniter, so please excuse the simple question. I spent about 30 minutes googling it but none of the solutions worked for me. Simply put, I wish to have my admin controllers in a subdirectory like to: /application/controllers/admin/home.php /application/controllers/admin/login.php My home.php looks like: Code: <?php My login.php looks like: Code: <?php My routes.php contains nothing custom: Code: $route['default_controller'] = "homepage"; With this setup: http://www.mysite.com/index.php/admin/login <=== does not work (404) http://www.mysite.com/index.php/admin/home <=== works! I'm coming from Zend, so I'm still getting my head around the CI routes. In the long run, it would be nice to have a route that basically said, "route URLs that look like /admin/controller/action appropriately" Thanks! - Bret
[eluser]PhilTem[/eluser]
You will not need any routes to allow URIs of type "example.com/admin/controller/method" to the corresponding controller as long as it is located in Code: APPPATH . 'controllers/admin/'; because CI automatically checks for a folder called admin if it does not find a controller/file called admin.php in Code: APPPATH . 'controllers/'; Anyway, I'm wondering why admin/home works for you and admin/login doesn't. Did you try accessing admin/home/index and admin/login/index separately?
[eluser]clone45[/eluser]
Ah, Well, I figured it out. It wasn't CodeIgniter's fault. Somehow I ended up with my login.php controller being blank. I don't know how that happened. It must have been some bug in my Aptana editor or, more likely, a problem between the chair and the keyboard (me). Ha ha ha. Thanks for the explanation on how routes work with folders. - Bret |
Welcome Guest, Not a member yet? Register Sign In |