如何在REST API中更改URI?

I am coding a REST API with php. I want the URI to be .../product/{id} but to get returned a specific "product". -I need to type in ..../product/read_one.php?product_id=7 - read_one is the php file

-I type the URIs in Postman.

How can I change it to .../product/7?

I am confused whether I can even use an .httaccess file or if I have to change up/create a new php file. I haven't found any tips on the internet either.

You can use .htaccess to do it:

RewriteEngine On
RewriteRule ^product/([0-9])+$ ./product/read_one.php?product_id=$1

Basically when a request is made to a url that matches the left side regular expression, it's the same as going to the path on the right.

This specific regular expression checks for atleast 1 number after product/.