B
B
BonBon Slick2018-12-03 10:58:32
JavaScript
BonBon Slick, 2018-12-03 10:58:32

Link masking?

Please read the question carefully before answering!

There is a link to google.com, and visually on the site it is necessary to issue mystie.com, by clicking on it the user will go, get the content of the masked link, in our case go to Google. Should only work for specific links.
There must be a masked link in the DOM, that is, the link can be changed in 3 places before rendering the document, client (js), server (nginx, php).
Most likely, you can write some rules using a regular expression and set up a proxy for nginx, this seems to be the simplest, you can’t touch the database, there 1 column should be url, no url_mask. Of course, you can also come up with something in php, during the return of the object, give a link that will lead to a real link, only here you need to store the original link and the camouflage one somewhere.
For each user, the link is different, it is unique and one-time, after reloading the page, the masking link is different.
How do they do it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Wolf, 2018-12-03
@BonBonSlick

As far as I understand, it is necessary to show the user a one-time link, and after he clicks on it, switch to the real one. It is impossible to implement a one-time transition without touching the database, that's for sure.
The only thing that comes to mind is to make the path look like /redirect/[hash], where [hash] is a regular link (google.com), which is encrypted with some kind of symmetric encryption. That is, we give the user https://mysite.ru/redirect/abcdef, when the user clicks on it, we get abcdef, decrypt and redirect the user to a normal link.
If it is necessary that an error be shown to the user when it is reopened, then it is necessary to store somewhere whether the user has already clicked on it. At best, you can limit the link in time by adding a temporary signature there and checking it on the redirect route.

D
Dmitry, 2018-12-03
@dimoff66

<a href="www.google.com">mistie.com</a>
mistie.com

N
nvdfxx, 2018-12-03
@nvdfxx

<a href="mistie.com">mistie.com</a>

$('a').on('click', function() {
    $(this).attr('href', 'google.com')
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question