0
所以在我的routes.php文件的文件我有這樣的:爲什麼我在Laravel的路線返回404錯誤?
Route::get('contact', function() {
return view('contact');
});
當我去domain.com/contact我得到一個返回的錯誤。但是當我把:
Route::get('/', function() {
return view('contact');
});
並轉到domain.com頁面出現。任何想法可能會造成這種情況?
完全routes文件:
<?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工匠路線:列表回報:
+--------+----------+---------+------+---------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+---------+------+---------+------------+
| | GET|HEAD |/ | | Closure | web |
| | GET|HEAD | contact | | Closure | web |
+--------+----------+---------+------+---------+------------+
你能分享你的routes.php更多的代碼嗎?也許所有的路線呢?這可能是因爲在路線上有前綴的路線組,您有錯誤 –
這是我嘗試上班的第一條路線,但是我將它張貼了,因爲我擁有它。 – Nash
嘗試在前面的聯繫路線添加一個「/」...路線::獲得('/聯繫',功能....' –