Symfony\Component\HttpKernel\Exception\NotFoundHttpException Laravel
A NotFoundHttpException
exception in Laravel always means that it was not able to find a router for a particular URL. And in your case this is probably a problem in your web server configuration, virtual host (site) configuratio, or .htaccess configuration.
Your public/.htaccess should look like this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
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>
As you can see there is a condition in the first line IfModule mod_rewrite.c
, so if you don`t have mode_rewrite installed or enabled, all rewrite rules will fail and this
localhost/Test/public/
Will work fine, but not this:
localhost/Test/public/test
In other hand, this one should work too, because this is its raw form:
localhost/Test/public/index.php/test
Because Laravel needs it to be rewritten to work.
And note that you should not be using /public, your URLs should look like this:
localhost/Test/
This is another clue that your virtual host's document root is not properly configured or not pointing to /var/www/Test/public, or whatever path your application is in.
All this assuming you are using Apache 2.
Before my web.php
was like below
Route::group(['prefix' => 'admin', 'middleware' => ['role:admin']], function() {
Route::resource('roles','Admin\RoleController');
Route::resource('users','Admin\UserController');
});
In url enterd
http://127.0.0.1:8000/admin/roles
and get the same error. The solution was :
Route::group(['middleware' => ['role:admin']], function() {
Route::resource('roles','Admin\RoleController');
Route::resource('users','Admin\UserController');
});
Remove 'prefix' => 'admin', as both Controllers are located in Admin folder
I had this case. I checked all of my codes and my solution was:
php artisan route:cache
Because I forgot to clear the route cache.