首页 > 系统相关 >nginx禁止PDF文件直接打开,而是下载

nginx禁止PDF文件直接打开,而是下载

时间:2022-11-23 10:46:08浏览次数:44  
标签:文件 header Content nginx add PDF 下载

在nginx.conf文件中加入下面代码

        location / {
            if ($request_filename ~* ^.*?\.(html|doc|pdf|zip|docx)$) {
                add_header  Content-Disposition attachment;
                add_header  Content-Type application/octet-stream;
            }           
        }

标签:文件,header,Content,nginx,add,PDF,下载
From: https://www.cnblogs.com/d-d-g/p/16917538.html

相关文章