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>
相关推荐
专注前端30年3 小时前
【PHP开发与安全防护实战】性能调优手册
android·安全·php
oMcLin3 小时前
如何在 RHEL 7 上优化 Nginx 与 PHP‑FPM 配置,确保高并发 Web 应用的稳定性与响应速度?
前端·nginx·php
IT=>小脑虎7 小时前
PHP零基础衔接进阶知识点【详解版】
开发语言·学习·php
xifangge20257 小时前
PHP 接口跨域调试完整解决方案附源码(从 0 到定位问题)
开发语言·php
ICT董老师8 小时前
通过kubernetes部署nginx + php网站环境
运维·nginx·云原生·容器·kubernetes·php
bleach-9 小时前
buuctf系列解题思路祥讲--[SUCTF 2019]CheckIn1--文件上传以及user.ini的应用
nginx·web安全·网络安全·php
BingoGo10 小时前
免费可商用商业级管理后台 CatchAdmin V5 正式发布 插件化与开发效率的全面提升
vue.js·后端·php
AI 智能服务21 小时前
第6课__本地工具调用(文件操作)
服务器·人工智能·windows·php
松涛和鸣1 天前
49、智能电源箱项目技术栈解析
服务器·c语言·开发语言·http·html·php
晚枫歌F1 天前
io_uring的介绍和实现
开发语言·php