SEO friendly urls http://example.com/mymethod,name_of_article,2 |
[eluser]jacobson[/eluser]
Hello I wanted to create more friendly urls for my CI application with a structure : http://example.com/mymethod,name_of_article,2. How can I make my app to examine URL like this and take it's 1'st parameter as method in the controller, second as the name of article (for SEO) and last - article ID. Thx for help
[eluser]ravengerpl[/eluser]
For example your method is named "post" and controller "blog". To get urls like Code: mysite.com/posts,name,id routes.php Code: $route['posts,(:any),(:num)'] = "blog/post/$1/$2" blog.php Code: public function post($name, $id) post_model.php Code: public function get_post($name, $id) There may be typos somewhere but hope you get the idea. Remember to add some error handling (when you deleted post from database and someone clicked on old link etc.).
[eluser]jacobson[/eluser]
Yup i think ill make it that way. The title of the post won't be used in queries, just the id ![]() |
Welcome Guest, Not a member yet? Register Sign In |