Reputation: 986
I am using Laravel 5.3.28, PHP 5.6.15 in XAMPP 5.6.15
In my file routes\web.php I add
Route::get('/about', 'DefaultController@about');
(the controller, the method and the view exists)
php artisan route:list return
+--------+----------+------------+------+----------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------+------+----------------------------------------------+--------------+
| | GET|HEAD | / | | App\Http\Controllers\DefaultController@home | web |
| | GET|HEAD | about | | App\Http\Controllers\DefaultController@about | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
+--------+----------+------------+------+----------------------------------------------+--------------+
and when I try to browse the Not Found Exception is raised. Looking for the error in the forum I understand that is due to an incorrect configuration of Laravel or .htaccess file. I don't understand how correctly fix the problem and why in the documentation it is not mentioned the need of this file. Thanks to all for any kind of help or suggestions.
UPDATE
Here follow as requested the error message
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 766
at Router->findRoute(object(Request)) in Router.php line 621
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 54
Upvotes: 2
Views: 3931
Reputation: 986
As i wrote in comment to the original question I found the .htaccess file in public folder. I modify the rules in this way
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
RewriteBase /mylaravel/public/ #----> ADDED THIS
RewriteRule ^(.+)$ index.php/$1 [QSA,L] #----> TWO ROW
# RewriteRule ^ index.php [L] #----> INSTEAD OF THIS
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
In this way the URLs:
use the correct route.
Upvotes: 2