How to Convert Query String to Segment URI?

前端 未结 3 1643
栀梦
栀梦 2020-12-22 03:14

I\'m trying to convert a query string;

http://atwd/books/course?course_id=CC100&format=XML&submit=Submit

Into a segment URI;

<
3条回答
  •  一生所求
    2020-12-22 03:50

    If I'm understanding you correctly, you might be over-thinking it. I have something similar in my own code.

    I have a controller named Source. In that controller, I have the following method:

    public function edit($source_id, $year)
    {
        # Code relevant to this method here
    }
    

    This produces: http://localhost/source/edit/12/2013, where 12 refers to $source_id and 2013 refers to $year. Each parameter that you add is automatically translated into its own URI segment. It required no .htaccess trickery or custom routes either.

提交回复
热议问题