WP like URI routing |
[eluser]lerio[/eluser]
Hi everyone, I need to know if is there a way to change this: http://my_site.com/my_class/my_method/my_parameter to this: http://my_site.com/my_paramenter I know this may sound crazy but that's what WP does for its articles and I need to do that on CI for SEO reasons. Thanks in advance
[eluser]Jelmer[/eluser]
You can always send everything to a single controller: Code: $route[':any'] = 'controller'; But if you do that you'll have to add every other controller specificly BEFORE that rule: Code: $route['other_controller(/:any)?'] = 'other_controller$1'; EDIT: correction to the other_controller rule (forgot the question mark)
[eluser]Jelmer[/eluser]
Hmm, just a quick correction: I forgot the quesion mark at the end of the $route for other controllers: Code: $route['other_controller(/:any)?'] = 'other_controller$1'; As such it will work both when yourdomain.com/other_controller is requested, and when yourdomain.com/other_controller/somefunction is requested. The previous route would only work on the second example but not on the first (controller without explicit function).
[eluser]lerio[/eluser]
Thanks, that worked. This is how I obtained WP-like URIs with CodeIgniter, like: http://www.my-site.com/my-article http://www.my-site.com/tag/my-tag http://www.my-site.com/category/my-category open config/routes.php and add the following lines: Code: $route['tag/(:any)?'] = 'my-controller-1/my-method-/$1'; like said before, order is very important. Thanks again |
Welcome Guest, Not a member yet? Register Sign In |