pathinfo配置全局生效的原因后,发现部分目录转发其他服务器代理不能生效,访问的路径还是走pathinfo路径。分析原因,原来是在是否进入要加入一个location / 匹配,否则全部都会到pathinfo。比如我的www.dnsdizhi.com/mptest/public/xxx 变成请求www.dnsdizhi.com/mptest/public/index.php/xxxx
location ~ /mptest/public/ {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
#proxy_cache tmpcache;
#proxy_cache_valid 200 304 1m;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://jingchang-api;
proxy_pass_header Set-Cookie;
expires 10m;
}
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
set $path_info “”;
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)?$
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_read_timeout 300;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location / {
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}
美国
哇,这篇文章是相关的信息材料,这将有助于你。 这个博客给我留下了深刻的印象,仅仅是因为作者用一条非常漂亮的线条向公众传达了一条信息。 作者的写作技巧太好,所以我会把这篇文章推荐给其他人。