2

I use Lumen 5.4.

This is how my route is setup:

$app->get('/ip/{ip}', GeoIpController::class . '@show');

The {ip} route parameter should be an IP address, with dots in it. However, it seems there is a problem when a route has dots in it. It returns a 404 not found error.

I am aware I could pass the IP address in as a simple GET request parameter, but want the IP to be part of the URL and to be handled like a route parameter.

For testing purposes, I use php -S localhost:8080 -t public to serve the application.

4

1 回答 1

8

这是对 PHP 内置服务器的限制,而不是 Lumen(或 Laravel,或 Slim,或任何其他带有路由器的框架/应用程序)。您可以在此处查看 PHP 错误报告

基本上,如果 URL 在脚本名称后的 url 中有一个点,则内置服务器会将请求视为静态文件请求,并且它不会真正尝试运行应用程序。

这个请求在真实的 web 服务器(apache、nginx)上应该可以正常工作,但是在 PHP 的内置开发 web 服务器上运行时会失败。

于 2017-05-19T19:26:22.557 回答