A-A+

lnmp开启PATHINFO模式的方法

2015年07月08日 Linux 暂无评论 阅读 3,692 views 次

nginx默认是不支持pathinfo模式,需要修改vhost配置文件

 

lnmp1.1下

去掉#include fastcgi.conf的注释,

把include pathinfo.conf放到include fastcgi.conf的前面。

注释掉#try_files $uri =404;

 

lnmp1.2,lnmp1.3下

是include enable-php.conf;替换为include enable-php-pathinfo.conf;

原理都是一样只是将配置统一到一个文件,修改更方便

如果还是不行,记得检查php.ini是否已经设置cgi.fix_pathinfo=1

 

Nginx下ThinkPHP的隐藏index.php和Pathinfo模式配置实例

server

{

listen 80;

#listen [::]:80;

server_name api1.xxx.com;

index index.html index.htm index.php default.html default.htm default.php;

root /home/wwwroot/chenxi/api1.XXX.com/public;

#include other.conf;

#error_page 404 /404.html;

include enable-php-pathinfo.conf;

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 12h;

}

location ~ /\.

{

deny all;

}

location / {

if (!-e $request_filename) {

###一级目录下

rewrite ^/(.*)$ /index.php/$1 last;

###域名下的二级目录

#rewrite ^/目录名/(.*)$ /目录名/index.php/$1 last;

}

}

access_log off;

}

记得加入红色文字,这一段!

 

更新于2016年7月11日

给我留言