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

现在它就像一个魅力。

相关问题