On my website, I am loading the content dynamically from database like this
e.g mysite.com/about-us
for this, there is an enrtry in database, so it will load the content for ‘about-us’ & print it using “page” controller only.
for this what I have done is, I have added below configuration in routes.php
$route[':any'] = "page";
but lets say if I already have controller named “about-us” and I want to load that & not the one from database, how can I do that?
A smooth solution would be to use the error/missing_page controller and point it in the
config/routes.php.Then it would automaticly pick all existing controllers first, and then that controller.
You can also call
show_404()if you don’t find a record in the database.This allows you to create new controllers without having to point all of them in the route file.
Read about 404 override here