Php 拉威尔-不';t工作路线

Php 拉威尔-不';t工作路线,php,laravel,ubuntu,routing,http-status-code-404,Php,Laravel,Ubuntu,Routing,Http Status Code 404,我在本地主机上有Laravel(如果有必要的话,在Ubuntu上) 我有这样的路由,它在localhost/public上工作/ 但是,如果我尝试使用这样的路由创建像localhost/public/test这样的新页面: Route::get('/test', function () { $tasks = Task::orderBy('created_at', 'asc')->get(); return view('layouts/tasks', [ '

我在本地主机上有Laravel(如果有必要的话,在Ubuntu上)

我有这样的路由,它在localhost/public上工作/

但是,如果我尝试使用这样的路由创建像localhost/public/test这样的新页面:

Route::get('/test', function () {
    $tasks = Task::orderBy('created_at', 'asc')->get();

    return view('layouts/tasks', [
        'tasks' => $tasks
    ]);
});
它返回:

404 (The requested URL /public/test was not found on this server.) 

另外,我尝试了
/test/
test
/public/test
,但这些都不起作用。

做另一个路由,只需输入一个return语句来检查它是否起作用。如果你得到另一个404,你的.htaccess文件可能不会生效

您需要在虚拟主机内为DocumentRoot启用AllowOverride All

大致如下:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

选项索引跟随符号链接
允许超越所有
要求所有授权

只需将您的AllowOverride更改为All或添加即可。

创建另一条路线,然后简单地输入return语句以检查它是否有效。如果你得到另一个404,你的.htaccess文件可能不会生效

您需要在虚拟主机内为DocumentRoot启用AllowOverride All

大致如下:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

选项索引跟随符号链接
允许超越所有
要求所有授权

只需将AllowOverride更改为All或添加即可。

您使用的是Apache还是NGINX?您应该首先修复/public问题。是否启用了
mod rewrite
?您使用的是Apache还是NGINX?您应该首先修复您的/公共问题。是否启用了
mod rewrite