For example I have a project with the structure below
project
|_src
|_public
|_index.php
And I run in public folder.
php -S localhost:8000
When I access
http://localhost:8000/random/request/uri
Here is the termial when I access the url above;
It seems like every url will always go back to index.php file. I wonder why and how. Can anyone explain to me?
I tried to search but I don’t know the keyword so….
2
Answers
Thank you Álvaro González. The answer was documented in https://www.php.net/manual/en/features.commandline.webserver.php
"If an index.php or index.html is found, it is returned and $_SERVER['PATH_INFO'] is set to the trailing part of the URI. Otherwise a 404 response code is returned."
It behaves that way because that is how the PHP built-in development server was designed to work.
From the documentation: