Home  >  Article  >  Backend Development  >  How to remove index.php in nginx

How to remove index.php in nginx

王林
王林Original
2020-08-18 16:57:575213browse

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

How to remove index.php in nginx

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

(推荐教程:php图文教程

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

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

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

The above is the detailed content of How to remove index.php in nginx. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn