Issue
I am annoyed with encountering mysterious problem. My development environment has been created with the following directory structure.
document_root
└ project
├ application
│├ controllers
││└ admin
││ ├ Users.php
││ ├ Facility_Categories.php
││ └ Facilities.php
│└ views
│ └ admin
│ ├ users
│ │└ index.twig
│ ├ facility_categories
│ │└ index.twig
│ └ facilities
│ └ index.twig
└ public
└ index.php
In the development environment, these URLs appeared as expected.
https://www.example.com/project/admin/users/
-> load admin/Users.php index function
https://www.example.com/project/admin/facilities/
-> load admin/Facilities.php index function
https://www.example.com/project/admin/facility_categories/
-> load admin/Facility_Categories.php index function
Recently, when I upload these files to a test environment. URL were not displayed correctly that contained "underscore". It looks like controller is not loaded.
https://www.example.com/project/admin/users/
-> load admin/Users.php index function
https://www.example.com/project/admin/facilities/
-> load admin/Facilities.php index function
https://www.example.com/project/admin/facility_categories/
-> 404 Page Not Found (display codeigniter show_404 function)
By the way, if the URL is capitalized, the controller will load but View will not. (view is also displayed if view's direcotry name is capitalized.)
https://www.example.com/project/admin/Facility_Categories/
-> 500 Internal Server Error
(Twig\Error\LoaderError : Unable to find template "admin/Facility_Categories/index.twig")
I want to access with lower case URL. How can I solve the problem?
Solution
I solved this problem on my own to read following url
CodeIgniter Controller Case-Sensitive
CodeIgniter3 seemed to have to capitalize only the first letter of the controller name and all lowercase after that. (OK: Facility_categories.php
NG: Facility_Categories.php
)
I just changed 2 points.
- Change Controller File Name From
Facility_Categories.php
ToFacility_categories.php
- Change Controller Class Name From
class Facility_Categories
Toclass Facility_categories
Now I can access to url that contain lowercase and underscores
https://www.example.com/project/admin/facility_categories/
Answered By - qwe001
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.