Say I have a controller, "Articles" but I want it to appear as a sub-folder (e.g. "blog/articles"), I can add a route like this:
$route['blog/articles'] = 'articles';
$route['blog/articles/(:any)'] = 'articles/$1';
This works fine, the only problem now is that example.com/articles
and example.com/blog/articles
both use the Blog controller and thus resolve to the same content. Is there a way to prevent this?
To add a little more clarity in case people aren't understanding:
- In this example, I don't have a 'blog' controller, but I want 'articles' etc to appear to be in that subfolder (it's an organization thing).
- I could have a blog controller with an 'articles' function, but I'm likely to have a bunch of 'subcontrollers' and want to separate the functionality (otherwise I could end up with 30+ functions for separate entities in the blog controller).
- I want
example.com/articles
to return a 404 since that is not the correct URL,example.com/blog/articles
is.