I’m coding a blog for a side project in Codeigniter. There will be three modules in my blog.
What I need to know how to do, for example:
- example.org -> show all posts with module3 theme
- example.org/module1 -> shows only posts of module1 with module1 theme
- example.org/module2 -> shows only posts of module2 with module2 theme
- example.org/module3 -> shows only posts of module3 with module3 theme
Any thoughts how to deal with this in the URL schema? (Routing)
You can do a simple switching:
In your routes:
How to implement not-existing cases is up to you now, this is just a start. Also, the “:any” route is a catch-all that will grab any url, so you’ll need to exclude (by placing them before any other routes you want to remap. Or you could take a look at the _remap() function to use in your controller