0

For example:

url(`https://example.com/file.exe`)

If a user visits this website directly, the user will be redirected to https://example.com/getfile.html but allow the user to get the file if the user gets the file from <a> tag of https://example.com/getfile.html

Joshua
  • 3,055
  • 3
  • 22
  • 37
Baigei
  • 11
  • 5
  • We don't know what your backend language is. With PHP you could make a difference between GET calls en POST calls. – Wimanicesir Oct 07 '21 at 09:11

1 Answers1

1

You can achieve this by removing href attribute in anchor tag and adding onclick function to the anchor tag. In onclick function send some parameter in url to get that value in your html page when user visits the page.

Click here to know how to send parameter in url.

Click here to know how to get post parameter from the url .

Still you have any confusion, you can comment your questions to this answer.

If you are using php you can get post parameter from url in a single line of code by using $_REQUEST["your post parameter name"];

I am adding a simple example for this to achieve with simple html and jquery.

with jquery document.referrer method on document ready(when user opens a page), you can get the previous url of user visited. like bellow example. for this you need to include jquery in your page by following line inserting in your page.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
  console.log(document.referrer);
if(document.referrer == "your url") {
    your code to allow user if comes from the url you mentioned //user will get download button or you can write direct download option;
} else {
     window.location = "some url";   //you can redirect user to specific url
}
});
<script>