Reputation: 2645
I am making a CMS-like website for myself and one component will be a blog. Ideally, I'd like the routes to be /blog-category/blog-slug
I'm wondering what the best way to achieve this would be?
I'll have a table for categories and a table for the individual posts.
A possible solution would be to use:
$route['(:any)/(:any)'] = 'blogController/getBlogPost'
However, I suspect this would have an effect on performance, I'd rather not send all requests to the posts controller, I'd rather just send them to the correct controller from the routes files.
Is there another way to loop through the categories and make a dynamic route?
Tom
Upvotes: 0
Views: 454
Reputation: 16117
You can use correct route as:
$route['blog-category/(:any)'] = 'blogController/blogFunction/$1';
For this URL:
/blog-category/blog-slug
In route $1
is using for your slug
.
Upvotes: 1