所以,在我的routes.php文件中,我有这个:
Route::get('contact', function() {
return view('contact');
});
当我访问domain.com/contact时,出现返回错误。然而当我输入以下内容:
Route::get('/', function() {
return view('contact');
});
当我访问domain.com时,页面出现了。有什么想法是什么原因造成的吗?
完整路由文件:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('homeIndex');
});
Route::get('contact', function() {
return view('contact');
});
php artisan route:list的返回结果:
+--------+----------+---------+------+---------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+---------+------+---------+------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | contact | | Closure | web |
+--------+----------+---------+------+---------+------------+
Route :: get('/ contact',function ....
- Tommy Leephp artisan routes
或php artisan route:list
,看看你的路由是否存在! - Ismail RBOUHartisan route:clear
,说不定会有帮助! - Ismail RBOUH