I'm building a tutorialsystem with codeigniter and would like to achieve the following URL structure:
- /tutorials --> an introduction page with the list of all the categories
- /tutorials/{a category as string} --> this will give a list of tutorials for the given category, e.g. /tutorials/php
- /tutorials/{a category as string}/{an ID}/{tutorial slug} --> this will show the tutorial, e.g. /tutorials/php/123/how-to-use-functions
- /tutorials/add --> page to add a new tutorial
The problem is that when I want to use the first two types of URLs, I'd need to pass parameters to the index function of the controller. The first parameter is the optional category, the second is the optional tutorial ID. I've did some research before I posted, so I found out that I could add a route like tutorials/(:any), but the problem is that this route would pass add as a parameter too when using the last URL (/tutorials/add).
Any ideas how I can make this happen?