Route with dot (IP address) not found, returns 404

删除回忆录丶 提交于 2019-12-24 11:56:01

问题


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.


回答1:


This is a limitation on PHP's built in server, not with Lumen (or Laravel, or Slim, or any other frameworks/apps with a router). You can view the PHP bug report here.

Basically, if the URL has a dot in the url after the script name, the built-in server treats the request as a static file request, and it never actually attempts to run through the application.

This request should work fine on a real web server (apache, nginx), but it will fail when run on PHP's built-in development web server.



来源:https://stackoverflow.com/questions/44074051/route-with-dot-ip-address-not-found-returns-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!