Rewriting URLs without invoking a different controller

Hi everyone, I'm new to CI.

I run a news site. Our article URLs look like this:

In my current system, I use .htaccess to rewrite all URLs to point to article.php?section=news&category=sport&story=ronaldo-signs-with-milan - a little lengthy, but it works. I realise that if I was to apply these URLs to CodeIgniter, it would look for a 'news' or 'features' controller, rather than routing all of these requests through one 'article' controller.

I looked briefly over the URI class, but I'm not certain if it's meant for this kind of thing. Can anyone give me a quick example (if it's possible) of how to achieve these kind of URLs while maintaining a normal CI structure?

If it helps, I'm completely happy to include ID numbers in links (eg if that makes it easier.


[eluser]Phil Sturgeon[/eluser]
Take a look at URI Routing.

$route['(news|features)/(:any)'] = 'articles/$1/$2';

That should do the trick.

Thanks, worked great! Confusing as I dive into pagination but I think I have it, cheers!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.