Loza Lowa
Loza Lowa

Reputation: 41

Translate Apache .htaccess to Lighttpd and mod_headers

I have started to use Lighttpd and I have this .htaccess file which alters the response headers.

<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>

How can I translate this to work in Lighttpd?

Upvotes: 4

Views: 890

Answers (1)

Kinetic
Kinetic

Reputation: 1744

You will need to use the following:

setenv.add-response-header = ( "Content-Disposition" => "attachment" )
setenv.add-response-header = ( "Content-Type" => "application/octet-stream" )
setenv.add-response-header = ( "Content-Transfer-Encoding" => "binary" )

I imagine you are trying to force file downloads as opposed to displaying the file in the browser? If this is the case you only need the application/octet-stream MIME-Type as per RFC 2046 ( https://www.rfc-editor.org/rfc/rfc2046 )

'The recommended action for an implementation that receives an "application/octet-stream" entity is to simply offer to put the data in a file, with any Content-Transfer-Encoding undone, or perhaps to use it as input to a user-specified process.'

Upvotes: 3

Related Questions