当前的浏览器能够识别文件格式,如果浏览器本身能够解析就会默认打开,如果不能解析就会下载该文件。比如txt文件就直接被解析,还有其他文件也是一样。

在nginx.conf配置文件中添加

add_header Content-Disposition "attachment; filename=$1"

nginx 配置下载text等文件

 

 

 alias : 对应文件存储地址,指定的目录是准确的,即location匹配访问的path目录下的文件直接是在alias目录下查找的

autoindex on  自动创建索引on是打开 off关闭

 

add_header Content-Disposition "attachment; filename=$1";
alias D:/fpfj/;
autoindex on;

  

 浏览器输入地址,直接下载文件

nginx 配置下载text等文件

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2021-08-09
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-28
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案