【发布时间】:2016-12-08 13:27:06
【问题描述】:
所以在我的 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 |
+--------+----------+---------+------+---------+------------+
【问题讨论】:
-
你能分享更多你的routes.php代码吗?也许其中的所有路线?这可能是由于在您遇到错误的路由顶部有带有前缀的路由组
-
尝试在您的联系方式前面添加一个“/”...
Route::get('/contact', function.... -
@Nash 请试试这个命令
php artisan routes或php artisan route:list看看你的路线是否在那里! -
php artisan route:list如果你使用的是 laravel 版本 >5 -
这真的很奇怪!请尝试清除缓存
artisan route:clear谁知道!