首页  >  文章  >  后端开发  >  nginx怎么去除index.php

nginx怎么去除index.php

王林
王林原创
2020-08-18 16:57:575214浏览

nginx去除index.php的方法:首先打开nginx.conf配置文件;然后在虚拟主机下添加配置【if (!-e $request_filename){rewrite ^/(.*)$ /index.php/$1 last;}】即可。

nginx怎么去除index.php

配置Nginx.conf在你的虚拟主机下添加:

(推荐教程:php图文教程

location / {
     if (!-e $request_filename){
          rewrite ^/(.*)$ /index.php/$1 last;
     }
}

(学习视频推荐:php视频教程
如果你的项目入口文件在一个子目录内,则:

location /目录/ {
     if (!-e $request_filename){
          rewrite ^/目录/(.*)$ /目录/index.php/$1 last;
     }
}

以上是nginx怎么去除index.php的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn