Welcome Guest, Not a member yet? Register   Sign In
Routing to specific controller in case controller/method is not found.
#2

(This post was last modified: 09-25-2015, 10:42 AM by mwhitney.)

I'm not sure I completely understand your issue, but any route which is specifically defined in the routes config will be matched before any RegEx rules are evaluated (':any' or ':num' is converted to a RegEx). So, if you have:
Code:
$route['sub-site'] = 'sub_site';

Then example.com/sub-site will work. Of course, that still creates an issue for the routes beneath it (example.com/sub-site/blog, etc.). For that, you would need to define another RegEx route for your sub-site, which means the router will loop through the list of RegEx routes until it finds a match.

This means that you need to define your RegEx routes in order from the most specific to the least specific in order to correctly match a route. So, your sub-site RegEx must be defined before your '(:any)' route. Once you do this, the only issue you should run into is that you won't be able to use 'sub-site' as a slug unless you use the URL example.com/page/view/sub-site.
Reply


Messages In This Thread
RE: Routing to specific controller in case controller/method is not found. - by mwhitney - 09-25-2015, 10:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB