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

1
  • We don't know what your backend language is. With PHP you could make a difference between GET calls en POST calls. Commented Oct 7, 2021 at 9:11

1 Answer 1

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> 
Sign up to request clarification or add additional context in comments.

8 Comments

What is the technology you are using in backend except html, javascript
i have updated answer with jquery code. please check once
Yes I know, but I think this only can use in html, but I want it to affect my file.exe
You can acheive this only with jquery. With html you cannot get the users previous url or if he comes direct
I don't know what languge can I use to do that in the file.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.