How to use CI with multiple folders |
[eluser]Mareshal[/eluser]
A friend made me a challenge. Access a controller inside a folder tree. For example. I have /controllers/folder_1/folder_2/folder_3/controller.php and I want in my browser example.com/folder_1/folder_2/folder_3/controller/function_name is this possbile?
[eluser]Michael Wales[/eluser]
Don't use folders to alter your URL, use URI Routing.
[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...llers.html Quote:Organizing Your Controllers into Sub-folders
[eluser]physicsdave[/eluser]
[quote author="Michael Wales" date="1265395143"]Don't use folders to alter your URL, use URI Routing.[/quote] Agreed, I've use both methods but have found that routing is the easiest to use/maintain and is far more flexible. CI even makes it easy, for the most part you won't have to learn regular expressions if you don't want to. Check it out: http://ellislab.com/codeigniter/user-gui...uting.html
[eluser]Mareshal[/eluser]
So, if i really want to use multilevel folder simply is not possible right?
[eluser]Carl_A[/eluser]
Hi, Im having a similar problem: I have subfolders in the controllers folder. It works with a complete index.php URI however, doesnt work when I add the .htaccess file.. What I mean is: I have -> application/controllers/admin/controller_name.php It works when I do www.example.com/index.php/admin/controller_name, But as soon as I add the .htaccess file, www.example.com/admin/controller_name gives me a 'file not found' error. My Aim: Have subfolders to organize my controllers. Can someone help? My .htaccess file: (with ref to this: http://codeigniter.com/wiki/mod_rewrite/ ) Code: <IfModule mod_rewrite.c>
[eluser]Mareshal[/eluser]
1. if you don't have an index() function in your controller, call another function from your controller see if it works 2. RewriteCond %{REQUEST_URI} ^system.* don't have this in my htaccess
[eluser]Carl_A[/eluser]
1. I do have an index() function.. and strangely everything works as long as I dont put the .htaccess file and use a complete link with index.php ( www.example.com/index.php/admin/controller_name ) It works perfectly with these links. 2. I followed the article here : http://codeigniter.com/wiki/mod_rewrite/ Every other controller (outside the subfolder) works perfectly with both www.example.com/index.php/controller_1 And www.example.com/controller_1 Its just the ones with the subfolder thats causing a problem.
|
Welcome Guest, Not a member yet? Register Sign In |