1
I have a . zip file in a folder on my server and I don’t want direct external links to it, only through a link on my own site. So I created a . htaccess in the file folder and put:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?meudominio.com.br [NC]
RewriteRule \.(zip)$ - [NC,F,L]
This basically solves the external link problem, but:
If someone sticks the link in the address bar and follows, can they still download it? How I could also block direct access (without reference)?
How can I redirect these already distributed links to a URL (like the original link) instead of showing the prohibited access page?
Referencing can be easily manipulated and thus circumvented, this is a terrible strategy of "security". It would be more interesting to work with session and/or token, which is too broad for me to answer here.
– Guilherme Nascimento
No problem, it’s not exactly a paid or responsive file. The idea is just to make external linking difficult because I miss too many visits.
– Daniel Lemes
I couldn’t understand the second question "How can I redirect these already distributed links to a url (like the original link) instead of showing the forbidden access page?"
– Guilherme Nascimento
– Bacco
Answering Guilherme: I mean redirect the link to the file (which has already been distributed there) to the download page. I can do a 301, but this is redirecting the link.
– Daniel Lemes
So there are 2 redirects taking place from a first link when only one should occur? It’s confusing, it seems another problem, by the way I think I should not use 301, I should use 302, pq 301 is permanent and if you do not know what you are doing and did something wrong will be forced to clean the cache and resetting some more things.
– Guilherme Nascimento