How to remove index.php in nginx

王林
Release: 2023-03-04 18:04:01
Original
5328 people have browsed it

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;
     }
}
Copy after login

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

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!