CodeIgniter controller in subfolder - codeigniter

I have a controller in a subfolder. CodeIgniter is giving a 404 page not found.
The controller works fine in the root controller folder. The controller also works fine in the 1st level subfolder. The controller breaks in the 2nd level subfolder.
Why would CodeIgniter not want you to user multiple subfolders?
Example:
Works: controllers/pages/HomeController.php
Broken: controllers/pages/users/HomeController.php
My Routes are like this:
Works: $route['default_controller'] = "pages/HomeController";
Broken: $route['default_controller'] = "pages/users/HomeController";

I wrote about this before, you just need to read the CI manual, but here is a quick blog entry I did which should get you back on track:
http://blog.biernacki.ca/2011/12/codeigniter-uri-routing-issue-with-controller-folders/
Example:
$route['account/manage/(:num)/(:any)'] = "account/manage/index/$1/$2";

CodeIgniter does not inherently allow for multiple controller folders. It may or may not work, but it is an undocumented quirk. Using the routes.php file you can virtualize any folder or controller structure you want, just take care to map your routes back to a controller and method in the Controllers folder.

Related

Codeigniter - dots in a controller folder name

I'm using the latest version of Codeigniter and I try to achieve specific controller folders structure.
I'm would like to create a controller folder for each of my webapp version:
/controllers/1.0.0/login (where login is the name of the controller)
/controllers/2.0.0/login (where login is the name of the controller)
the problem: it seems Codeigniter working great with controller folders but not working with controller folders that contain dot :(
Like this working good (without dots):
/controllers/100/login (where login is the name of the controller)
/controllers/200/login (where login is the name of the controller)
Is there a way to make Codeigniter work with dots on controller folders?
Thanks
Shai
I also getting the same issue.
You can use like this in your route
config/route.php
$route['Controller/1.0.0/login'] = 'Controller/100/login';
$route['Controller/2.0.0/login'] = 'Controller/200/login';
This is working fine for me

Encrypt URL with PHP Codeigniter

I have developed a website with PHP Codeigniter. It consists of many controllers and views. I want to encrypt the URL of the site to hide the controller and function name. Currently, the URL looks like this :
www.sitename.com/controller_name/function_name
I don't want the users to see the controller and function names. Is it possible to do this now because the site is almost complete. Is there any shortcut of doing this? Please Help
You can use codeigniter URI Routing to remove your controller name from URL.
$route['url_name'] = 'controller_name/function_name';
This `www.sitename.com/url_name` will look go to `www.sitename.com/controller_name/function_name`
$route['url_name/(:any)'] = 'controller_name/$1';
This will only change your controller name.. `controller_name` to `url_name`

Codeigniter working directory inside another working directory

Hi I am working on codeigniter for a while now and have met with an issue.
I use "localhost/controller/function" which is how codeigniter works.
Where controller classes are in controller folder in application.
I have a new codeigniter setup in root folder names "big" with its own controller, view, models etc. How can I run files in "big" like I do for my the original application.
I tried "localhost/big/controller/function", which obviously didn't work.
Please help, I am completely new with codeigniter.
just go to index.php of your application (big)
change/add line:
$application_folder = "applications/big";

What is the maximum layer of subdirectory at codeigniter controllers

I have a a project(codeigniter) where file directory is like that.
mysite
application
config
controllers
super_admin
admin.php
tasks
setup
bank.php
assets.php
Now if I try to access
http://localhost/mysite/tasks/seutp/bank
It calls codeigniter 404 page
But I can access
http://localhost/mysite/tasks/assets
Actually I can get access any controller under controllers and controllers/tasks folder.
But I cannot get access under controllers/tasks/setup folder
My question is
Is there any limitation of sub-directory at codeigniter?
If Yes: Is there any way to solve the limitation and How?
If No: Why I cannot access the third layer sub-directory controllers?Did I do something wrong?
yes there is a default for the ci controllers file folder levels. i am using this solution:
https://degreesofzero.com/article/controllers-in-sub-sub-folders-in-codeigniter.html
the author includes a lengthy mod rewrite but if you already have a working htaccess rewrite file to eliminate index.php from the url then it will probably work as is.

CodeIgniter url not working for new class

I uploaded CodeIgniter in my server, and the basic page works fine.
Then I added home.php file in application/controllers folder with class Hello and function one, and tried to open the link url/index.php/Hello/one but I get the codeIgniter error that the page isn't found. What can I be missing?
To fix your issue you should rename the Hello class to Home then go to URL/index.php/home/one
I recommend that you read up on the controller documentation:
http://ellislab.com/codeigniter/user-guide/general/controllers.html
A Controller is simply a class file that is named in a way that can be
associated with a URI.
Consider this URI: example.com/index.php/blog/
In the above example, CodeIgniter would attempt to find a controller
named blog.php and load it.
When a controller's name matches the first segment of a URI, it will
be loaded.

Resources