CodeIgniter 404 Page Not Found, but why?
Solution 1
The cause of the problem was that the server was running PHP using FastCGI.
After changing the config.php to
$config['uri_protocol'] = "REQUEST_URI";
everything worked.
Solution 2
You could try one of two things or a combination of both.
- Be sure that your controller's name starts with a capital letter. eg "Mycontroller.php"
- If you have not made any changes to your route, for some strange reason, you might have to include capital letters in your url. e.g if your controller is 'Mycontroller.php' with a function named 'testfunc' inside it, then your url will look like this: "http://www.yourdomain/index.php/Mycontroller/testfunc". Note the capital letter. (I'm assuming you haven't added the htaccess file to remove the 'index.php' part. If you have, just remove it from the url.)
I hope this helps someone
Solution 3
Leaving this answer here for others who ran into my situation.
My codeigniter app was working fine in localhost/WAMP, but was unable to route and produced 404 not found errors when pushing to an AWS EC2 instance. My issue was solved from the answer from HERE htaccess works in localhost but doesn't work in EC2 instance
(route to my admin page) {domain}/admin was producing 404
the /etc/httpd/conf/httpd.conf
file needs to be modified.
-after every instance of "DocumentRoot "/var/www/html"" (2 places) "AllowOverride None" needed to be changed to "AllowOverride All".
Restarted the EC2 instance from the AWS dashboard.
{domain}/admin is now accessible and working as intended.
hope this helps someone else like it helped me!
Solution 4
- Change your controller name first letter to uppercase.
- Change your url same as your controller name.
e.g:
Your controller name is YourController
Your url must be:
http://example.com/index.php/YourController/method
Not be:
http://example.com/index.php/yourcontroller/method
Solution 5
If you installed new Codeigniter, please check if you added .htaccess file on root directory. If you didn't add it yet, please add it. You can put default content it the .htaccess file like below.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Comments
-
Joseph about 3 years
I am using CodeIgniter for two applications (a public and an admin app). The important elements of the document structure are:
/admin /admin/.htaccess /admin/index.html /application /application/admin /application/public /system .htaccess index.php
The /admin/.htaccess file looks like this:
DirectoryIndex index.php RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
The /admin/index.php has the following changes:
$system_folder = "../system"; $application_folder = "../application/admin"; (this line exists of course twice)
And the /application/admin/config/routes.php contains the following:
$route['default_controller'] = "welcome"; $route['admin'] = 'welcome';
Welcome is my default controller.
When I call up the Domain/admin I get a 404 Page Not Found error. When I call up the Domain/admin/welcome everything works fine. In the debug logs I get the following error message:
DEBUG - 2010-09-20 16:27:34 --> Config Class Initialized DEBUG - 2010-09-20 16:27:34 --> Hooks Class Initialized DEBUG - 2010-09-20 16:27:34 --> URI Class Initialized ERROR - 2010-09-20 16:27:34 --> 404 Page Not Found --> admin
Weirdly enough this setup works perfectly on my local MAMP installation (with the localdomain/admin/), but when I publish and test it on the "live" server, I just get 404 errors.
Any ideas? What am I doing wrong? Thanks C.
-
Matthew over 13 yearsThat's actually how I structure my applications. I have an admin app and a web app. They both share a system folder ('../system'), and each have a separate app folder ('../application/admin'), ('../application/website').
-
Joseph over 13 yearsIt is based on this: codeigniter.com/user_guide/general/managing_apps.html There is only one system folder. I moved the application folder to the same level as the system folder.
-
Joseph over 13 yearsI meant that in the /admin/index.php file I have changed lines 26, 43 and 101
-
Kuf over 9 yearsThe routing started working, but now the CLI returns
Welcome to CodeIgniter
screen. anyway around it? I've posted more information here -
logicbloke over 6 yearsController indeed needs to be capitalized but accessing it through the URL does not necessarily require you to put the capital letter in the URL.