0
点赞
收藏
分享

微信扫一扫

nginx 修改配置文件使之支持pathinfo,且隐藏index.php


声明环境:

nginx
centos6.8
使用lnmp一键包搭建环境(2019年2月19日 )

以前使用过别的办法去修改配置文件,但是过于繁琐,最近发现新版本中,在​nginx​ 的 ​conf​目录下发现了文件“​enable-php-pathinfo.conf​”,随后发现另外一种及其简单让​nginx​支持​pathinfo​的修改办法。

首先找到你的 ​nginx.conf​ 文件。

我本人使用的是一键环境,​nginx.conf​ 所在目录为:​​/usr/local/nginx/conf​

如果找不到可以使用命令:​​find / -name .user.ini​

nginx 修改配置文件使之支持pathinfo,且隐藏index.php_php

打开文件,找到

nginx 修改配置文件使之支持pathinfo,且隐藏index.php_隐藏index.php_02

找到 ​​include enabled-php.conf​​ 更换成 ​​include enable-php-pathinfo.conf;​​即可

nginx 修改配置文件使之支持pathinfo,且隐藏index.php_服务器_03

随后重启服务器:​​service nginx restart​

nginx 修改配置文件使之支持pathinfo,且隐藏index.php_nginx_04

已经可以访问,接下来去掉​index.php

继续在​nginx.conf​文件中修改,在其文件中增加:

nginx 修改配置文件使之支持pathinfo,且隐藏index.php_服务器_05

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

随后重启服务器:​​service nginx restart​

解决~



举报

相关推荐

0 条评论