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.
Essentially, the “404 error” indicates that your or your visitor's web browser was connected successfully to the website server or the host. However, it was unable to locate the requested resource, such as filename or any specific 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.
Please make sure you have Apache configured with the following information in /path/to/apache2/installation/conf/httpd.conf
<Directory "path/to/laravel/project/public">
Allowoverride All
</Directory>
For the .htaccess
file located in the public/
folder, make sure it includes the following:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymlinks
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Then enable the Apache mod_rewrite
module:
sudo a2enmod rewrite
I had the same Issue & resolved it by changing the way Routes were ordered.
Before:
Route::get('/p/{post}', 'PostsController@show');
Route::get('/p/create', 'PostsController@create');
After: (and the that 404 disappeared)
Route::get('/p/create', 'PostsController@create');
Route::get('/p/{post}', 'PostsController@show');
try
php artisan route:clear
php artisan route:cache
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/*'
];
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With