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.
Changing the server port worked for me after trying several fixes all to no avail. I was running on loalhost:3000 and changed to localhost:4000. I think this might have to do with some memory cahe
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
This is old question but is active yet.
for windows users if you using CAPITAL characters (upper-case letter) in your project folder you should using same in your browser.
If your project is in "c:\xampp\htdocs\MyProject\" you should using MyProject as url instead of myproject
for example in the above project (MyProject) following route:
Route::get('/dashboard', function () {
return 'welcome to dashboard!';
});
will work if you use:
http://MyProject/dashboard
but is better using lowercase characters in directories
and then type this and see whether your route exists in the list
php artisan route:list
and also in Middleware\VerifyCsrfToken.php check post routes are allowed
class VerifyCsrfToken extends Middleware {
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'api/*'
];
}
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 was going crazy about my routes not working and here is also a quick fix. I had the following route: users/{user}/user-detail-changes/{user-detail-change}/update-status
The fix was to rename parameters. Laravel doesn't accept minus character -.
Rather than that you have to use camelCase or underscore (_) variable naming conventions.
So it has to be like: users/{user}/user-detail-changes/{userDetailChange}/update-status
Hello! I also encountered this problem before. Please check your Apache's httpd.conf file. Make sure that you enabled the LoadModule rewrite_module modules/mod_rewrite.so by removing the # from the start line of the code.
And also change inside the httpd.conf from Require all denied to Require all granted, AllowOverride All, and Options Indexes FollowSymLinks
For me, it was issue with .htaccess file.
Make sure you have the .htaccess in public_html folder.
I downloaded this file from one server but the dot(.) was removed by the downloader. Then when I uploaded in another server, the dot(.) was missing and I got 404.
My .htaccess looks like below:
# disable directory browsing, but specific file browsing is possible, e.g. /js/bootstrap.js
Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch
#To set which file will be acted as index file: DirectoryIndex index.php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
# deny from some DDoS attackers ip
# deny from 69.171.251.0/24
# php -- BEGIN cPanel-generated handler, do not edit
# This domain inherits the “PHP” package.
# php -- END cPanel-generated handler, do not edit
Im using Homestead, and after being stuck for quite some time trying everything that there was to try, what finally worked was re-checking my Hosts file (/etc/hosts on *nix systems), verifying my Homestead.yaml configuration file, and running the 'provision' command on the Homestead Vagrant Box.
The provision seems to have cleared some caches previously held or deployed the currently working site, honestly can't understand what changed since the databases were working and unit tests were passing.
But leaving it here in case it can help somebody out.
one thing i would like to add for user's who use nginx server and have configured server blocks(virtual hosts). check which server block is activated in your nginx conf files.
also in /etc/hosts file check whether you are using correct url to your server block or not.
When at the time of website hosting there is the problem 404 Not Found Error on requested pages. At That time there is only home page is work fine. And if i request another page for e.g. mydomain.com/any_page then it sends me to the 404 Not Found Error Then i looked at my controller files and other routes files to solve the problem. Finally i think there is absent of the .htaccess file When i just added the .htaccess file to the same folder of the index.php of the laravel project then it juts works file.
Conclusion
By adding the .htaccess file at the same folder location of the index.php it solves the 404 page not found error in my laravel Project.
For me it was a permissions issue. User I was logged in with didnt have the necessary assigned role that gave the required permission to view said URL/section.
this can also happen if, for an API route, the Content-Type is not set to application/json when validation fails for a given request. This was the issue in my case.
I had the same issue. The reason was that i was making https requests but i did not set-up https configuration in apache vhost. So apache was sending 404.
Query string length: By default, Microsoft IIS accepts a maximum query
string length of 2048 characters. If IIS receives a query string that
is longer than 2048 characters, it will generate a 404.15: Query
String Too Long error URL length: Like the query string, each browser
has a limit on the length of the URL it supports. For example,
Internet Explorer accepts a maximum URL length of 2083. If the URL
length exceeds the limit, you'll get a 404.14: URL too long error.
I always get 404 error when I tried to access following URL from the browser:
http://localhost/attachment/filename.ext
After many hours of struggle and an advise from a friend, I finally found out that the filename.ext is treated differently in Laravel (as physical file), hence I need to change the filename parameter to either of one below:
using base64encode(filename), or
create parameter to split the filename into filename_only and extension (e.g. myfilename.txt into myfilename and txt)