您好我正在努力使用nginx配置中的pdf的add_header。我希望浏览器以内联方式提供pdf,但它正在为用户下载文件。 我在配置文件中有这个
location ~* /(.*\.pdf) {
types { application/octet-stream .pdf; }
default_type application/octet-stream;
add_header Content-Disposition "inline";
}
我也尝试过遵循add_header语法 add_header Content-Disposition:inline; 和 add_header Content-Disposition:“inline”;
如果可以,请帮忙。我在配置文件中也有以下内容。
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass 127.0.0.1:9000;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
我使用了注释中提到的以下语法和fireforx修复来解决问题。 location〜* .pdf $ { if($ uri~“^ / upload /(.+。pdf)$”){ 设置$ filename $ 1; } add_header Content-Disposition“inline; filename = $ filename”; }