将Apache的.htaccess翻译成Lighttpd和mod_headers格式

4

我已经开始使用Lighttpd,有一个.htaccess文件可以更改响应头信息。

<IfModule mod_headers.c>
    Header unset Content-Type
    Header unset Content-Disposition
    Header set Content-Disposition attachment
    Header set Content-Type application/octet-stream
    Header add Content-Type application/force-download
    Header add Content-Type application/download
    Header unset Content-Transfer-Encoding
    Header set Content-Transfer-Encoding binary
</IfModule>

我该如何将这个翻译成适用于 Lighttpd 的代码?
1个回答

3
你需要使用以下内容:
setenv.add-response-header = ( "Content-Disposition" => "attachment" )
setenv.add-response-header = ( "Content-Type" => "application/octet-stream" )
setenv.add-response-header = ( "Content-Transfer-Encoding" => "binary" )

我想你是想强制下载文件而不是在浏览器中显示文件?如果是这种情况,只需要按照RFC 2046的建议使用application/octet-stream MIME类型(https://www.rfc-editor.org/rfc/rfc2046)。
“对于接收到'application/octet-stream'实体的实现,推荐的操作是仅仅提供将数据放入文件的选项,并取消任何Content-Transfer-Encoding,或者将其用作用户指定进程的输入。”

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接