在我的网站上我有:
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,我有一个生成此图像的脚本。
答案 0 :(得分:0)
尝试添加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' "*";
}
...