Table of Contents

,

Download file from apache website by sending custom header

Download some file from URL like https://domain.com/somedir/myfile.tar.

In apache host configuration add this:

SetEnvIf X-My-Token "mysecrettoken" my-token
Alias /somedir /var/www/somedir
<Directory /var/www/somedir/>
    Require env my-token
</Directory>

Then you can use wget to get the file and pass it the secret:

wget --header='X-My-Token: mysecrettoken' https://domain.com/somedir/myfile.tar --output-document=/home/user/Downloads/myfile.tar

Tested on

See also

Password protect site with htaccess in Apache

References