How does nginx rewrite static URLs into dynamic ones?

WBOY
Release: 2023-03-01 19:32:01
Original
1182 people have browsed it

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! !

Reply content:

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>
Copy after login

Thanks for the invitation.

<code>
https://laravel-china.org/topics/688
</code>
Copy after login

Set up the routing.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!