首頁  >  文章  >  後端開發  >  nginx怎麼去除index.php

nginx怎麼去除index.php

王林
王林原創
2020-08-18 16:57:575212瀏覽

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