Home > Article > Backend Development > How does nginx rewrite static URLs into dynamic ones?
I used lumen to make the api interface. The url is static, similar to this:
https://www.foo.com/api/v1/ar...
The id here is the required parameter.
But when I call the interface, I use this URL format to pass parameters:
https://www.foo.com/api/v1/ar...
Can I directly change the url format to support it in laravel or lumen? Inquiry form?
Or implement it by rewriting it in the rewrite method of nginx. How to rewrite it specifically?
Thank you! !
I used lumen to make the api interface. The url is static, similar to this:
https://www.foo.com/api/v1/ar...
The id here is the required parameter.
But when I call the interface, I use this URL format to pass parameters:
https://www.foo.com/api/v1/ar...
Can I directly change the url format to support it in laravel or lumen? Inquiry form?
Or implement it by rewriting it in the rewrite method of nginx. How to rewrite it specifically?
Thank you! !
This does not require URL rewriting and routing
<code>Route::any('api/v1/article', function(Request $request){ $id = $request->input('id'); if (empty($id)) return 'parameter "id" invalid. '; return redirect('api/v1/article/'.$id); }) Route::any('api/v1/article/{id}', 'ArticleController@index');</code>
Thanks for the invitation.
<code> https://laravel-china.org/topics/688 </code>
Set up the routing.