Slim Framework always return 404 Error

后端 未结 8 610
独厮守ぢ
独厮守ぢ 2021-02-01 04:27

These days i\'m using Slim Framework as my simplest tool to develop the php web api. Using these two articles:

  • Coenraets
  • CodingThis
8条回答
  •  忘掉有多难
    2021-02-01 05:05

    Problem is solved!

    My apache is actually normal, and the .htaccess file provided earlier also normal.

    The clue is the URL that I used. Previously I used the invalid URL, thus it returned the 404 page error. I just realized it when I Tried to access the newer GET URL via browser with this one;

    http://localhost/dev/index.php/getUsers/user1
    

    and now that works!

    I just realized it once I found these statements;

    If Slim does not find routes with URIs that match the HTTP request URI, Slim will automatically return a 404 Not Found response.

    If Slim finds routes with URIs that match the HTTP request URI but not the HTTP request method, Slim will automatically return a 405 Method Not Allowed response with an Allow: header whose value lists HTTP methods that are acceptable for the requested resource.

提交回复
热议问题