Welcome Guest, Not a member yet? Register   Sign In
Is it possible to establish a catchall controller method?
#14

(12-19-2014, 12:13 PM)albertleao Wrote:
(12-19-2014, 10:29 AM)sneakyimp Wrote:
(12-17-2014, 05:45 PM)ivantcholakov Wrote: Sorry,




Code:
$route['(.+)'] = 'catchall/index/$1';

Wouldn't this router mean that one's entire site was always handled by that one router? This is not what I want. I want CodeIginiter to first match any controllers I have defined in the controllers directly and only after none have been matched do I want to rely on the catchall. I believe the 404_override is what I want here.

No. The routes file is read from top to bottom so if you put this at the end of your routes file it should only catch it if you don't have any other routes setup. That being said, you need to have other routes setup.

Thanks for the clarification. This approach would mean that I must specify some routing rule for each of my controllers rather than just letting CI do it's natural routing. This is undesirable because it means the devs on my project must all make changes to routes.php file if controllers are added or removed. I think he 404_override is preferable for this reason. Unless I'm missing something...
Reply


Messages In This Thread
RE: Is it possible to establish a catchall controller method? - by sneakyimp - 12-21-2014, 02:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB