Skip to content
Advertisement

Not found route in Laravel 7

Making a website on Laravel 7.28. Added a route to ‘routes/web.php‘:

JavaScript

The controller is created in ‘appHttpControllersLKIndexController.php‘. It has a method:

JavaScript

Created promoter file ‘resourcesviewslkindex.blade.php‘. When I’m trying to follow the route http://127.0.0.1:8000/lk. I get an error:

The requested resource /lk was not found on this server.

If I change the ‘lk’ routes to the ‘account’, for example, then at ‘http://127.0.0.1:8000/account’ I get the page correctly.

And it’s not entirely clear why 404 error doesn’t appear in Laravel view? Please help with this issue.Thank.

Advertisement

Answer

Issue:This error occurs when you create a folder/directory in the public folder with the same name as route slug(lk here).

Why public folder creating this issue: Any object inside public folder can be accessed via url(which is also a route).

If you have a directory(folder) with the same name as route mentioned, it will create 404 because /directory can’t be accessed due to blocking of directory traversal for security reasons but if you use /directory/<a_file_or_image> it will show you the requested object.

When you have a route with same name as directory inside public folder, it is being override by public path. When you change to another route name, it works fine.

Solution: Either change public folder name or change route slug.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement