CodeIgniter Forums
CI links question - 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: CI links question (/showthread.php?tid=28654)



CI links question - El Forum - 03-17-2010

[eluser]bogdan3l[/eluser]
Hello!

It is possible to make links with CI like wordpress(http://www.example.com/2010/03/17/my-post/)?

I don't like http://www.example.com/controller-name-or-function-name/my-post/...!

Could somebody help me? An example or something would be great!

Thank you


CI links question - El Forum - 03-17-2010

[eluser]nelson.wells[/eluser]
Look into routing in the user guide. It lets you re-route a url to a controller/function/parameters. Once you've come up with a url scheme, it's fairly easy to construct routes to use the controllers/methods you want.

So if you wanted a scheme such as http://www.example.com/blog/april/cross-site-scripting, then your route could look like this.

$route['blog/(:any)/(:any)'] = "blog/get_post/$1/$2";

Where blog (at the right side of equals) would be the controller, get_post would be the method in the controller, and $1 and $2 would be parameters to the method in the controller.

You can use regex instead of simple strings to do more complex routing techniques, too.


CI links question - El Forum - 03-17-2010

[eluser]bogdan3l[/eluser]
Thanks a lot for your reply, i will try right now.