Routing to specific controller in case controller/method is not found. |
Thank you for your interest @mwhitney.
Let me be more specific on the issue. Let's say, i'm showing list of blog posts on example.com/blog which points to controller/Blog.php->index() and, i'm showing single blog post on example.com/blog/view/post-slug-here which points to controller/Blog.php->view($slug) and maybe my contact page on example.com/contact which points to controller/Contact.php->index() these are expected behaviour of CI and should work perfecty. in addition to this scenario, (blog and contact page) there is another content (eg: page table on database) which i want to serve from url pattern like this: "example.com/page-title" there maybe tens of dynamic content. so i cannot create controller for each of these content. Exaple Page Table Code: ID TITLE CONTENT To archieve this behaviour i tried following route: PHP Code: $route['(:any)'] = 'page/view/$1'; Since this approach archieves my needs, it's also breaking other blogs/pages etc. Because any string just after example.com/anystring routing to [b]controller/Page.php->view($title)[/b] So, is there a way to tell to CI that, 1) If requested controller/method exists, execute it. ( eg: example.com/blog => controller/Blog.php->index() ) 2) And in case if it's not exists , execute a specified controller/method. |
Welcome Guest, Not a member yet? Register Sign In |