w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Force image download with htaccess

You can not force download with this rewrite.

Your server must serve this file (for example in http://subdomain.mydomain.com//img/my_fake_image.jpg). Then, modify you rewrite rule and add the following rule (not tested and to adapt)

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(subdomain.)?mydomain.com.*$ [NC]
RewriteRule .(jpg|jpeg|png|gif)$
http://subdomain.mydomain.com/img/my_fake_image.jpg [NC,R,L]
<FilesMatch ".my_fake_image.jpg$">
    ForceType application/octet-stream
    Header set Content-Disposition attachment
</FilesMatch>




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.