Add title in apache

I have apache and many images on this server. E. g .: http://test.com/images/abc.jpg I want to be able to do this: if the user goes to url, how should this http://test.com/images/download/abc.jpgapache add a header Content-Disposition: attachment; filename="abc.jpg". How can i do this?

+3
source share
1 answer

You want to use a combination of mod_rewrite (to fake the download directory) and mod_headers (to add a Content-Disposition header).

Create a .htaccess file in the image directory:

<filesmatch ". *">
Header set Content-Disposition attachment env = REDIRECT_force_download
& lt / filesmatch>

, REDIRECT_force_download.

.htaccess:

RewriteEngine On
RewriteRule (.*) ../$1 [L,NC,QSA,E=force_download:1]

() "REDIRECT_force_download", .

+5

Source: https://habr.com/ru/post/1732996/


All Articles