I've got a Codeigniter 3 site where all my routes work except my home page route, which is like so:
<?php
$route['default_controller'] = "front/homepage";
?>
If I create a new route as below I can access it as "/home" but nothing works for index. I get an error in my log as 404 Page Not Found: /index, in my config i have index set to blank.
<?php
$route['home'] = "front/homepage";
?>
Any ideas?
Thanks
This is no-longer supported in Codeigniter since V2 due to it being a bug in the routing logic.
http://www.codeigniter.com/userguide3/installation/upgrade_300.html#directories-and-default-controller-404-override
Related
I have writing codeigniter URL routes for my site, the route is
$route['index.php/([a-zA-Z0-9---_%])+'] = 'site/index/$1';
when i try to access the link like as below
http://localhost/site/index.php/india
is not working, it redirects to 404 page.
If you have a link
http://localhost/site/index.php/india
You need write this route:
$route['site/index.php/(:any)'] = 'site/index/$1';
So basically, I would like to load a CodeIgniter controller contents outside CodeIgniter's environment, that is, from a traditional PHP page.
I have tried the following but it doesn't suit my requirements:
<?php
require('/application/controller/error?type=not_found');
?>
It gives the following error:
Message: require(/application/controller/error?type=not_found): failed to open stream: No such file or directory
To clarify, I'm trying to change the default /application/errors/error_404.php page contents to this so it will display the custom HTTP 404 error page I've built in the "error" controller & view.
The problem is, The pages under /application/errors/ are treated as normal PHP pages by CodeIgniter which means I can't use $this->load-view('error'); inside the error_404.php page.
I would also appreciate other suggestions for ways to create custom error pages in CodeIgniter.
You should set the 404 page in the route.php page in the application/config folder:
$route['404_override'] = 'your-error-controller/your-error-view';
This route will tell the Router what URI segments to use if those provided in the URL cannot be matched to a valid route.
I might be confused at your question but the routes.php gives you a place where you can point the 404 page to a custom view.
I have set routes in routes.php for my default page but it shows a 404 error when opening localhost/mywebsite
$route['default_controller'] = "page";
$route['404_override'] = 'page';
I have set the above code in routes.php which gives a 404 error. The page controller has been created.
You need to make sure following things:
Webserver rewrite module is installed
htaccess file is properly configured
index function is present in page controller
You configured default controller & 404_override URL with the same value.
When ever you access to your web site automatically open page controller index function
ie ur_project_url/page/index
OR
ur_project_url/index.php/page/index
when ever you can get the 404 error also open same page controller index function
ie ur_project_url/page/index
OR
ur_project_url/index.php/page/index
please check your controllers and function and routes ,htacess file
please remove your url index.php using htacess
in config folder $config['log_threshold'] = 0; to $config['log_threshold'] = 1; check log files
I am trying to get rid of the 404 Page not found error while updating to Codeigniter 3.0
I am using Ion Auth and HMVC libraries. I have fixed Ion Auth issue and I believe (not so sure) that I have fixed HMVC issues as well. If not than don't know how to debug ^_^ it. But I have updated both libraries with the latest one from their respective repos.
I have logged in successfully but when system try to loads the first page after login it is giving 404 error and here are the logs
DEBUG - 2015-03-17 10:51:51 --> UTF-8 Support Enabled
DEBUG - 2015-03-17 10:51:51 --> Global POST, GET and COOKIE data sanitized
ERROR - 2015-03-17 10:51:51 --> 404 Page Not Found: ../modules/admin/controllers/dashboard//index
Notice: double slash in URI before last segment (index). Isn't it strange?
I wonder what is wrong here. I have tried uri_protocol by setting AUTO and REQUEST_URI too but none of them worked.
$config['uri_protocol'] = 'AUTO';
and
$config['uri_protocol'] = 'REQUEST_URI';
Now, I my development completely stuck. Can anyone help me to rid of this issue? Thanks a lot...!
Routes info
application/config/routes.php
$route['default_controller'] = "users/login";
$route['404_override'] = '';
application/modules/users/config/routes.php This is for Ion Auth
$route['users/(:any)'] = "auth/$1";
I have fixed my 404 redirect issue by capitalizing all my class file names in the controller folder and model folder.
So instead of main.php I did Main.php.
Hope this helps someone moving from CI 2 to CI 3.0
Capitalize all your controllers and models files.
Ex:
- controllers/Ajax.php
class Ajax extends MX_Controller {
... some magic stuff
}
I try almost everything for fixed my problem but I can't
This is my routes file in codeigniter.
$route['default_controller'] = "main";
$route['404_override'] = 'my_error_page';
$route['(:any)'] = 'page/index/$1/';
My website working well normally but 404_override not redirect to my_error_page.
I see standart codeigniter 404 page like the picture
When I delete last line like following;
$route['default_controller'] = "main";
$route['404_override'] = 'my_error_page';
404_override redirect to my error page and of course web site not running well.
It is maybe a simple problem but I am confused.
Sorry bad english.
Please help.
Thaank you.