laravel - 在 Laravel 返回 404错误时,为什么我的路由?

  显示原文与译文双语对照的内容
144 0

因此在我的routes.php 文件中,我有:

Route::get('contact', function() {
 return view('contact');
});

当我转到 domain.com/contact 时,返回返回错误。但是,当我放置时:

Route::get('/', function() {
 return view('contact');
});

然后转到 domain.com 页面显示。有什么可能会导致?

完整路由 file:

<?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工匠 route:list 返回:

+--------+----------+---------+------+---------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+---------+------+---------+------------+
| | GET|HEAD |/| | Closure | web |
| | GET|HEAD | contact | | Closure | web |
+--------+----------+---------+------+---------+------------+
时间:原作者:0个回答

143 3

好的我修正了我的问题。如果其他任何人都有这里问题,请确保服务器上启用了 mod_rewrite 。你可以通过进入终端进入

a2enmod rewrite

然后键入

service apache2 restart

它现在的工作方式。

原作者:
...