首页 > 解决方案 > Laravel 得到 Internal Server Error 怎么解决?

问题描述

Laravel 得到 Internal Server Error 怎么解决?

这是我的 web.php 代码

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

Route::get('/fleet', 'FleetController@index')->name('fleet');
Route::get('/offers', 'OffersController@index')->name('Offers');

当我链接到车队页面时,我会收到内部服务器错误。

我的文件夹是

resources
|-view
   |--index.blade.php
   |--fleet.blade.php
   |--offers.blade.php

这是 index.blade.php 代码

<li class="nav-item"><a class="nav-link" href="{{ route('fleet') }}">Fleet</a></li>
<li class="nav-item"><a class="nav-link" href="{{ route('offers') }}">Offers</a></li>

怎么解决?

我的 apache 设置是

DocumentRoot "D:\xampp\htdocs\laravel\wine\public"

我的 FleetController 代码

public function index()
    {
        return view('index');
    }

舰队模型

class Fleet extends Model
{
    //
}

仍然得到错误

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at postmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6 Server at localhost Port 80

标签: laravel

解决方案


请进一步了解laravel Route

最基本的 Laravel 路由只接受 aURI 和 aClosure

现在看看你的代码

Route::get('/fleet')->name('fleet');
Route::get('/offers')->name('offers');

你只给URI但你不给关闭

基本路线:

Route::get('/fleet',function(){
    // what do you want to do with that URI
})->name('fleet');

您还可以为控制器操作指定路由名称:

Route::get('user/profile', 'UserProfileController@show')->name('profile');

您需要UserProfileController为上述路线创建一个文件


推荐阅读