nginx去掉index.php 只需2个步骤

时间:2026-02-14 10:39:16

1、要编辑子站的配置文件

vi  /usr/local/nginx/conf/vhost/子站.conf

把 include enable-php.conf   注释掉这行!(或者直接dd删除)

然后在下面新曾一行  添加 

include enable-php-pathinfo.conf;   #注意后面必须带分号

2、进入目录   cd /usr/local/nginx/conf/vhost/子站.conf 

vi 子站.conf           在你的虚拟主机配置文件server段里添加以下内容:

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

3、浏览器打开 http://localhost/Home/Index/mod   访问正常!成功去掉了index.php

© 2026 一点知道
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com