Laravel The requested URL /hellowzy was not found on this server. 404 问题的解决

在一个Laravel项目中,新建了一个控制器及方法,路由,然后执行php artisan serve,这个方法是可以访问到的,可是部署到apache环境,根目录指向public目录,就报错了:

Not Found

The requested URL /hellowzy was not found on this server.

nally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

经查deepseek,发现可能是.htaccess的问题,

把.htaccess填充如下内容就ok了:

复制代码
 <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
相关推荐
DigitalOcean11 天前
Laravel 开发者已在 DigitalOcean 上开通超过 10 万台服务器
前端·laravel
两个人的幸福13 天前
Windows 桌面应用自研 PHP 队列(下):完整代码与六大工程化优化
php
BingoGo15 天前
PHP 泛型之殇 泛型 RFC 提案被拒绝
后端·php
JaguarJack15 天前
PHP 泛型之殇 泛型 RFC 提案被拒绝
后端·php
用户30745969820716 天前
PHP 扩展——从入门到理解
php
鹏仔先生16 天前
拷贝漫画APP下载页PHP程序,后台带免费AI写作
php
云水一下17 天前
从零开始学 PHP 系列(一):PHP 的前世今生与开发环境搭建
开发语言·php
xingpanvip17 天前
星盘接口开发文档:本命盘接口指南
android·开发语言·css·php·lua
酉鬼女又兒17 天前
零基础入门计算机网络运输层:端到端通信核心作用、端口号分类规则、复用分用工作机制及UDP与TCP协议全方位对比详解
网络·网络协议·tcp/ip·计算机网络·考研·udp·php
dog25017 天前
不要再继续优化 TCP
网络协议·tcp/ip·php