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

声明环境:

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

以前使用过别的办法去修改配置文件,但是过于繁琐,最近发现新版本中,在nginxconf目录下发现了文件“enable-php-pathinfo.conf”,随后发现另外一种及其简单让nginx支持pathinfo的修改办法。
首先找到你的 nginx.conf 文件。
我本人使用的是一键环境,nginx.conf 所在目录为:/usr/local/nginx/conf
如果找不到可以使用命令:find / -name .user.ini
查找
打开文件,找到
nginx 修改配置文件使之支持pathinfo,且隐藏index.php_第1张图片
找到 include enabled-php.conf 更换成 include enable-php-pathinfo.conf;即可

nginx 修改配置文件使之支持pathinfo,且隐藏index.php_第2张图片
随后重启服务器:service nginx restart
nginx 修改配置文件使之支持pathinfo,且隐藏index.php_第3张图片

已经可以访问,接下来去掉index.php
继续在nginx.conf文件中修改,在其文件中增加:
nginx 修改配置文件使之支持pathinfo,且隐藏index.php_第4张图片

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

随后重启服务器:service nginx restart
解决~

你可能感兴趣的:(nginx,配置)