Update 2020 There are many case happened above, I've once more case I met a long time but I still forget and sometimes I dont know why. This is some url patterns is the same, example abc.com/c/{get_an_id} and abc.com/c/get_text. You can change order but only first can run, 404 for the second url.
I'm not entirely sure why all the down-votes, especially since this is a common issue and the cause can be hidden for someone new to the Laravel environment. I know this is an old post, but I add it here for future newbies.
The first thing I suggest trying is running php artisan route:list from the command line (from your project root directory). This will list all the routes that Laravel can register and if there are any errors, usually they will show up here.
The second thing I suggest is to ensure that the URL matches route. I can't tell you how many times I've tried to figure out why my route was returning a 404 simply because my form was posting to something like /insertStudent when my route was defined as /admin/insertStudent
The third thing I suggest is to ensure the method you are calling exists. Are your methods really called postSignIn and postInsertStudent and not simply SignIn and InsertStudent? Keep in mind that both the URL and method names are case sensitive and should match where you define the route, the URL that is being called, and the method that is receiving the request.
Finally if all that checks out, one last thing I might suggest you try is running php artisan route:clear. This resets the route cache.
In my case I tried to access api endpoints and each time recieved 404 resource not found.
When I've added Accept: application/json header I got response from matched route
Update 2020
There are many case happened above, I've once more case I met a long time but I still forget and sometimes I dont know why. This is some url patterns is the same, example abc.com/c/{get_an_id} and abc.com/c/get_text. You can change order but only first can run, 404 for the second url.
I'm not entirely sure why all the down-votes, especially since this is a common issue and the cause can be hidden for someone new to the Laravel environment. I know this is an old post, but I add it here for future newbies.
The first thing I suggest trying is running
php artisan route:list
from the command line (from your project root directory). This will list all the routes that Laravel can register and if there are any errors, usually they will show up here.The second thing I suggest is to ensure that the URL matches route. I can't tell you how many times I've tried to figure out why my route was returning a 404 simply because my form was posting to something like
/insertStudent
when my route was defined as/admin/insertStudent
The third thing I suggest is to ensure the method you are calling exists. Are your methods really called
postSignIn
andpostInsertStudent
and not simplySignIn
andInsertStudent
? Keep in mind that both the URL and method names are case sensitive and should match where you define the route, the URL that is being called, and the method that is receiving the request.Finally if all that checks out, one last thing I might suggest you try is running
php artisan route:clear
. This resets the route cache.dontforget, the url is sensitive case to the folder name
Don't forget the order of your routes. For example, if you want to go to
/path/second
and have the following routes registered:This will break, as
second
is consumed by/path/{dynamic_second}
.If you want to access
/path/second
, you have to have your routes listed like so:make sure, the url passed is equal in your route. check the parameters and action in the form. To get clear answer post your mvc
Make sure you added correct
Accept
header.In my case I tried to access
api
endpoints and each time recieved 404 resource not found. When I've addedAccept: application/json
header I got response from matched route