CodeIgniter Forums

Full Version: URL routing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hello maybe anyone have idea how to make that type of url routing?
if i call i want that my app first check if exists entry in db by that article name and shows it from page controller, if it not exist then makes the other controller work.

Sorry for bad englishSmile

El Forum

I think this can't be done 'cause CI will load the controller if it exists.

You can however put a _remap call into the main controller, that will receive all calls, with the article name passed as an argument. So you check if the article exists in the database. But as I just noted, I think this won't work if a controller exists with the same name.

Another way can be using hooks. Before the controller is loaded, you can "intercept" the arguments.

But I wouldn't do that unless it is absolutely neccesary.

Why don't have a controller named "article":

this would be even better for users to remember the URLs.