Welcome Guest, Not a member yet? Register   Sign In
SEO, routing, redirecting without redirecting.
#2

[eluser]mddd[/eluser]
If you really want to be able to rewrite to ANYTHING, you should look at using an 'dynamic routes' solution. In such a case you use a selection of routes from your database instead of the routes in the routes config file. This is the only way you can achieve a route like 'labradors' => 'dogs/category/123'. Because otherwise, you will always need a controller with the right name (in this case "labradors").

If you make it a bit simpler, by keeping a correct controller name at all times (like 'dogs/labradors' => 'dogs/category/123') then you can handle things in a _remap method in the controller. Something like:
Code:
class Dogs extends Controller()
{
   function __remap()
   {
      // check here if the uri parts after 'dogs' make sense.
      // for instance by looking up the 'seo name' in your database and finding the correct values from there.
      $catid = $this->mymodel->get_cat_id_from_seo_name($this->uri->segment(2);
      $this->category($catid);
   }
}

The point of this is, that you don't switch to another controller. You stay in the right controller, and do your lookups from the _remap method. From that method, you can safely fire up the right method without doing a real redirect.


Messages In This Thread
SEO, routing, redirecting without redirecting. - by El Forum - 06-23-2010, 04:04 AM
SEO, routing, redirecting without redirecting. - by El Forum - 06-23-2010, 05:26 AM
SEO, routing, redirecting without redirecting. - by El Forum - 06-23-2010, 05:37 AM
SEO, routing, redirecting without redirecting. - by El Forum - 06-23-2010, 05:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB