Home  >  Q&A  >  body text

route - laravel routing, can pathinfo mode be implemented?

Target url: index.php/1/category/list? cate_id=12
Achieve the goal: after the number 1, the part before the question mark (i.e. category/list) is obtained as a parameter

Route::get('/{id}/*',function($id, $path){
    // 
}

The above code does not work, just understand the meaning.
The key to the problem is that the path part is of variable length, it may be first/second, or first/second/third.

How should routing be written?

ringa_leeringa_lee2713 days ago802

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 16:55:05

    // url: http://sf.gg/1/category/list?cate_id=12
     $path = Request::path();// /1/category/list
     $path = explode('/',$path,3)[2];// category/list

    reply
    0
  • Cancelreply