Z
Z
zaart2021-09-05 23:14:44
Apache HTTP Server
zaart, 2021-09-05 23:14:44

How to pass referrer to your own subdomain?

Hello!

Please tell me how you can transfer Referrer from your site.ru domain to demo.site.ru, and don't transfer anything for everything else?

Tried same-origin but didn't work. Is it possible to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Volintsev, 2021-09-06
@copist

By means of a client script it is possible. For example, on the site.ru page, use Javascript to extract Referer from HTTP and, when accessing demo.site.ru, substitute it in another HTTP header, for example, in X-Referrer

var referrer = document.referrer;
$.ajax({ // jQuery
    url: 'http://demo.site.ru/foo/bar',
    headers: { 'X-Referrer': referrer  }
});

For this, it is not necessary to change all scripts. Rules can be configured in one place for all requests made via jQuery

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question