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>
相关推荐
damoluomu1 天前
挑 PHP CMS 之前,先学会看它的协议
php
子非鱼a2 天前
【WEB】Online ToolWEB
php
PHP实战开发录2 天前
Nginx上传大文件为什么报413
nginx·php·开发
damoluomu2 天前
国产企业级 PHP CMS:哪些能免费商用
php
郑州光合科技余经理2 天前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程
MyFreeIT2 天前
Android PHP Manual
php
aixingpan3 天前
aixingpan.cn API开发文档:api_docs_trichart_natal_progression_sec_transit2接口指南
前端·php
sbjdhjd3 天前
从日志包含到临时文件竞争:文件包含进阶复盘中的 Docker、Windows 与 Session 限制
网络·安全·web安全·网络安全·数据挖掘·php·rce
daxiangxm3 天前
【趣味休息】“围住小猫在线玩”-“困住小猫”,又回来了
数据结构·人工智能·vscode·github·php
星光开发者3 天前
基于Spring Boot的充电桩管理系统的设计与实现-计算机毕设【课程设计】57105
vue.js·spring boot·vscode·mysql·django·php·express