开发者

How to do a redirect without the original referrer showing?

I need to do redir开发者_如何学Pythonect my site visitors to a third party site, without the original referrer showing as the urls disclose private information.

Is there a way to instruct a browser redirection without a referrer being sent to the destination site? E.g. using javascript?

Thanks


With JavaScript: You can create a link with referrer-suppressing attributes and then simulate a click on it.

var link = document.createElement("a");
link.referrerPolicy = "no-referrer";
link.rel = "noreferrer";

link.href = "https://example.org/";
link.click();

Alternatively, in a pure HTTP redirect, you can send the Referrer-Policy: no-referrer header along with the redirection.


As a quick workaround, you could redirect them to a special URL owned by you which exclusively redirects to the target URL (or one provided as a query parameter, for example). This way the private information would be lost in the extra hop.


Have you tried

<meta http-equiv="refresh" content="0;url=http://www.someplace.com">


You will need to redirect through another page. You can do a POST to your own page which then does a redirect to the destination. This will show only your intermediate page as the referrer.

There is not a way to do this with just javascript.


Try redirect with curl for example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜