lnmp1.0支持pathinfo模式

首先,在ssh中執行php


touch /usr/local/nginx/conf/pathinfo.conf 建立pahtinfo.conf文件css

而後在這個文件中添加如下內容html


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 ~ .*\.phpnginx

再在include fcgi.conf; 下面添加一行include pathinfo.conf;ssh

重啓nginx
完整的虛擬主機配置文件以下:unix

server
{
listen 80;
server_name iw3c.com;
index index.html index.htm index.php;
root /home/wwwroot/iw3c;server

location ~ .*\.php
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
include pathinfo.conf;
}htm

location /status {
stub_status on;
access_log off;
}ip

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}io

location ~ .*\.(js|css)?$
{
expires 12h;
}

}

相關文章
相關標籤/搜索