让军哥的lnmp1.0支持pathinfo模式
在网上找了很多写法,貌似都不支持LNMP1.0!!
我这里有一个军哥发的,测试过,可行!
首先,在ssh中执行
touch /usr/local/nginx/conf/pathinfo.conf
创建pahtinfo.conf文件
然后在这个文件中添加以下内容
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "(.+?.php)(/.*)") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
再将虚拟主机配置文件里的location ~ ..(php|php5)?$ 替换为:location ~ ..php
再在include fcgi.conf; 下面添加一行include pathinfo.conf;
重启nginx
完整的虚拟主机配置文件如下:
server
{
listen 80;
server_name iw3c.com;
index index.html index.htm index.php;
root /home/wwwroot/iw3c;
location ~ .*.php
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
include pathinfo.conf;
}
location /status {
stub_status on;
access_log off;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*.(js|css)?$
{
expires 12h;
}
}
求助,按照这个方法开启后,所有的/index.php?g=xx&m=Index&a=xx都变成了/.php?g=xx&m=Index&a=xx,怎么解决
谢谢,帮了我大忙~