繁体   English   中英

Nginx没有将某些位置重定向到php

[英]Nginx not redirecting some location to php

在我的网站conf上,我有:

location / {
    try_files $uri $uri/ /index.php?$args;
}


location ~* \.(ttf|ttc|otf|eot|woff|font.css|css|ico|js|gif|jpe?g|png|less|txt)$ {
    etag on;
    access_log off;
    log_not_found off;
    expires 180d;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    add_header 'Access-Control-Allow-Origin' "*";
}

location ~ \.php$ {
    include fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;

    fastcgi_read_timeout 5m;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 16k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_max_temp_file_size 0;

    proxy_set_header X-Forwarded-Proto $scheme;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

但是,然后我尝试访问http://my-site-url/images/profiles/uid-of-my-image.jpg它并没有重定向到php,我有一个生成该图像的脚本。

尝试添加一个root指令,指定静态文件与try_files $uri $uri/ /index.php?$args; 在您提供的第二个位置块中。 下面是一个示例配置:

...

location ~* \.(ttf|ttc|otf|eot|woff|font.css|css|ico|js|gif|jpe?g|png|less|txt)$ {

root /absolute/path/to/static/files;
try_files $uri $uri/ /index.php?$args;

etag on;
access_log off;
log_not_found off;
expires 180d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
add_header 'Access-Control-Allow-Origin' "*";
}

...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM