Search code examples
requestdetection

Detect from which page a file was requested


Let's say I load jQuery from a separate domain and host. Can this other host some how detect from which page it was requested from?

For example:

Can www.page-b.com somehow know that the link was requested from page www.page-a.com/subpage?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>this page is www.page-A.com/subpage</title>
<meta charset="utf-8">
</head>
<body>
<script src="http://page-B.com/js/jquery.min.js"></script>
</body>
</html>

Solution

  • You have to check the HTTP Referrer field of the request. How this is done depends highly on the used programming language. The referer field contains the URL of provenience of the request, which is exactly what you need.

    More information at https://en.wikipedia.org/wiki/HTTP_referrer