CodeIgniter Routing

后端 未结 3 1762
南笙
南笙 2020-12-14 13:33

I am developing an ecommerce website with CI that has product categories and products. I want to route the URL so that it will go to the products controller, then run the ge

3条回答
  •  余生分开走
    2020-12-14 13:51

    You should use the URI class to retrieve the "docupen" and "rc805" segments from your url. You can then use those values in whatever functions you need.

    For example, if your url is www.yoursite.com/products/docupen/rc805, you would use the following in your products controller to retrieve the segments and assign them to variables:

    $category = $this->uri->segment(2); //docupen
    $product = $this->uri->segment(3); //rc805
    

    Then you can use $category and $product however you need to.

提交回复
热议问题