Force Download PDF using Lighttpd

In lighttpd, to disabled PDF opening in browser, add following config files at lighttpd.conf. This is useful in increasing CTR as browsers usually get stucked while loading PDF files.


$HTTP["url"] =~ "(.*)\.pdf" {
mimetype.assign = (".pdf" =>"application/octet-stream")
setenv.add-response-header = ( "Content-Disposition" => "attachment" )
}

+ Dont forget to enable setenv module, if not already done …
server.modules += ( "mod_setenv" )

This is lighttpd version of my previous thread using apache.

Sources:

http://symkat.com/tag/content-disposition/
http://www.cyberciti.biz/faq/mod_setenv-lighttpd-send-custom-headers/

Share your thoughts & feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: