lnmp 一键安装包 nginx配置tp5 phpinfo模式 隐藏index.php

tp5 url 线*问 在nginx 上 出现404错误 那是因为pathinfo没有被支持

修改如下:找到   /usr/local/nginx/config/vhost/项目名.config

server
{
listen 80;
#listen [::]:80;
server_name swoole.houdianjing.cn ;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/swoole.houdianjing.cn/public; include other.conf;
#error_page 404 /404.html; # Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php-pathinfo.conf; #这一句支持pathinfo
#下面这6行隐藏index.php
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /.well-known {
allow all;
} location ~ /\.
{
deny all;
} access_log /home/wwwlogs/swoole.houdianjing.cn.log;
}

最后,又找到php.ini配置文件,

找到:cgi.fix_pathinfo=0
更改为:cgi.fix_pathinfo=1

从新运行lnmp restart;

上一篇:nginx 隐藏index.php 并开启rewrite日志调试(apache也有)


下一篇:Nginx配置PATHINFO隐藏index.php