To create custom / friendly Urls, you will need to use some route system in your project. Basically it is a place where you specify the Urls that your site/api has and which file will run when each url is accessed.
If you are using a web framework, it probably already has something integrated and that you can use. If you are doing everything using only PHP, Html, etc... you can look for some PHP-ready class to help you with this, I will leave an example below, but recommend to take a look at others and to see which one suits you best:
https://github.com/dannyvankooten/PHP-Router
You can also create your own route schema or urls using/configuring . htaccess to redirect the urls to the corresponding scripts, but it may take more work. I will leave here a tutorial on how to create your own:
https://alexandrebbarbosa.wordpress.com/2019/04/17/phpconstruir-um-sistema-de-rotas-para-mvc-primeira-parte/
If you have the option to use some framework in the project, I strongly recommend it, because it will probably already have all these routes and many other features ready and well organized. If you don’t want to leave PHP, the Laravel is an excellent option.