2016-08-03 96 views
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  | 
+--------+----------+---------+------+---------+------------+ 
+0

你能分享你的routes.php更多的代碼嗎?也許所有的路線呢?這可能是因爲在路線上有前綴的路線組,您有錯誤 –

+0

這是我嘗試上班的第一條路線,但是我將它張貼了,因爲我擁有它。 – Nash

+1

嘗試在前面的聯繫路線添加一個「/」...路線::獲得('/聯繫',功能....' –

回答

2

好了,所以我固定我的問題。如果其他人有這個問題,請確保您的服務器上啓用了mod_rewrite。您可以通過將終端和進入

a2enmod rewrite

做到這一點,然後鍵入

service apache2 restart

現在它就像一個魅力。

相關問題