Welcome Guest, Not a member yet? Register   Sign In
Strange 404 routes when having a specific file in /public/
#1

Here's a problem that's easy to cope with but still strange to me.

Say I have a presenter route defined as follows in /Config/Routes.php

PHP Code:
$routes->presenter('products', ['controller' => 'ProductsController']); 

and at the same time I have a products.txt file located in /public/ folder.

When I try to access /products/show/1 route I get a 404 Not Found.

I understand that the routes are created automatically and managed behind by the webserver but why is the .TXT not taken into account to differentiate the route and the file?
Reply
#2

php routing starts working if the resource specified in the url does not exist.

For url example.com/products.txt
the server will first look for the public/products.txt file, and if the file is not found, the server will pass control to the framework's routing.

For url example.com/products/show/1
first, the server will look for the file public/products/show/1, and if the file is not found, the server will pass control to the framework's routing.

If you get a 404 for /products/show/1, then there is no "public/products/show/1" file, or there is no "ProductsController" controller, or there is no "show" method in this controller, or this method returns 404.
Or your web server is not configured.
Reply
#3

Quote:Many thanks for your accurate reply
Reply




Theme © iAndrew 2016 - Forum software by © MyBB