问题描述:
laravel框架在路由设置里的web.php文件新增一个路由(如下图1),如果nginx里没有做任何配置,那么在访问新增路由时。url地址需要携带index.php+新增的路由(既:http://www.laraveldev.com/index.php/goods)
如下图1:

如果要在项目的URL中省去index.php 需做如下配置
在vhosts文件夹下当前项目的配置文件中添加以下代码重启就OK了
方法一:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
方法二:
if (!-e $request_filename) {
rewrite ^/(.*) /index.php/$1 last;
}
如图下图:

本文详细介绍了如何在Laravel项目中通过Nginx配置省去index.php,提供两种方法,包括try_files和rewrite规则,帮助开发者快速实现无index.php URL访问。
496

被折叠的 条评论
为什么被折叠?



