CodeIgniter Forums
Page slugs - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Page slugs (/showthread.php?tid=42397)



Page slugs - El Forum - 06-06-2011

[eluser]Wonder Woman[/eluser]
Hi,

I was wondering how I can change my urls so that they are friendly, for example:

example.com/news/my-first-article

instead of

example.com/news/1

and how would I change


example.com/privacy_policy

to

example.com/privacy-policy

I want to do this dynamically instead of configuring them individually in my routes.php file.

Thanks


Page slugs - El Forum - 06-06-2011

[eluser]fraserk[/eluser]
You can user $url_title to accomplish this.
Code:
$title = "What's wrong with CSS?";

$url_title = url_title($title);

// Produces: Whats-wrong-with-CSS