I have heard of people using slugs for generating clean urls. I have no idea how it works. Currently i have a codeigniter site which generates url's like this
From what i understand by maintaining a slug field it is possible to achieve urls like
How is this done? Especially in reference to codeigniter?
I just store the slugs in my database table, in a column called
slug, then find a post with the slug, like this:
Also, to easily derive a slug from your post title, just use
url_title()of the URL helper:
A little bonus: you may wish to implement a unique key constraint to the
slugcolumn, that ensures that each post has a unique slug so it's not ambiguous which post CodeIgniter should look for. Of course, you should probably be giving your posts unique titles in the first place, but putting that in place enforces the rule and prevents your application from screwing up.