Search code examples
phpcodeignitercodeigniter-routing

How to redirect every uri calls to one controller, except some static ones?


I'm using codeigniter and want to make my portal a bit more SEO friendly. I have a controller (articles) which handles every article on my portal. The URL looks like this:

example.com/articles/category-sub-category/article-name

I'm using mod rewrite module to hide my index.php, and codeigniter routing to hide the controller action that handles every call.

I want to hide articles too, but if I hide it, every call goes to the articles controller, and that's not what I want, because I want my URL to look like this:

example.com/category-sub-category/article-name

I've tried it with regexp routing rules in the routes.php but I found no way to make it right.


Solution

  • I answered this one pretty extensively a few days ago:

    How to get an array of all controllers in a Codeigniter project?