所以在我的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 |
+--------+----------+---------+------+---------+------------+
答案 0 :(得分:3)
好的,我解决了我的问题。如果其他人有此问题,请确保在您的服务器上启用了mod_rewrite。您可以通过转到终端并输入
来完成此操作 a2enmod rewrite
然后输入
service apache2 restart
它现在就像一个魅力。