[eluser]Pert[/eluser]
Depending on how exactly do you want to set up your URLs, you can use routing file if all your links follow some kind of a standard
Code:
$route['category/(:any)'] = 'category/details/$1';
So URL example.com/category/my-new-category loads controller category and runs method details with single attribute with value 'my-new-category'. From there you can see if that value is in your category table.
You can also use controllers _remap function. If present, when ever controller is called, only _remap function is called. You can check in that method what kind of link it is.
I myself use 404 override in route configuration file for my CMS. If URL does not translate to a meaningful controller, my custom 404 controller tries to figure out, what content is suppose to be shown, and displays it - or if it can't work out URL, it truely is a 404 page.