Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP webserver not falling back to index.php when URL has an extension #16194

Closed
nicolas-grekas opened this issue Oct 3, 2024 · 3 comments
Closed

Comments

@nicolas-grekas
Copy link
Contributor

Description

Create an empty dir and put Hello in index.php.
run php -S localhost:8080 in that directory

go to http://localhost:8080/foo/bar, see Hello.
go to http://localhost:8080/foo/bar.baz, see a 404 from the builtin webserver instead of the expected Hello.

This must be a recent regression?
PHP 8.4 is not affected, but PHP 8.2.24 and 8.3.12 are (I didn't test earlier versions)

PHP Version

PHP 8.2.24

Operating System

No response

@kallesommernielsen
Copy link

Interesting, I ran into something similar yesterday on 8.3.7 although my uri was something akin to /123/456.789

@damianwadley
Copy link
Member

In PHP 8.3 and earlier, if the URL indicates a file (it has an extension) then the server assumes the request was for a file and so would return 404 when it couldn't be found. Developers are expected to use a router script if something more complicated is needed, such as URL rewriting.

That will change in 8.4, where it will automatically route such a request to the closest index file.
https://github.com/php/php-src/blob/php-8.4.0RC1/UPGRADING#L23

@damianwadley damianwadley closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2024
@nicolas-grekas
Copy link
Contributor Author

nicolas-grekas commented Oct 3, 2024

Oh so this is how it worked since always? Funny I notice only now :)
Another good reason to move to PHP 8.4! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants