开发者

Is there a way a website can accurately determine the source domain that reached it?

开发者 https://www.devze.com 2023-01-11 20:06 出处:网络
I have a websi开发者_JAVA技巧te where I click on a link and am redirected to another website. Is there a way, the other website (www.otherwebsite.com) can determine accurately that the request has bee

I have a websi开发者_JAVA技巧te where I click on a link and am redirected to another website. Is there a way, the other website (www.otherwebsite.com) can determine accurately that the request has been sent from my website www.mywebsite.com?


Yes, using the HTTP header called "Referer" (no, that is not a spelling mistake, that is actually the name of the header).

For instance, in PHP you would do this:

<?php echo "You came from this site: <b>".htmlspecialchars($_SERVER['HTTP_REFERER'])."</b>";

The same code in JavaScript:

document.write("You came from this site: <b>"+document.referrer+"</b>");

This could output:

You came from this site: http://www.mywebsite.com/index.html


what language?

with javascript you can use : document.referrer with php you can use : $_SERVER['HTTP_REFERER']

however, there is NO method in any language that is 100% accurate, do to the ability to spoof headers.

0

精彩评论

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