If you have any questions about the access source, assume that my website is a.com with image a.com/123.png.
When B .com uses this image, what is http_referer?
Enter a.com/123.png http_referer in the address bar as B .com.
How can I determine whether an image is referenced by another website or accessed by a user directly?
Reply to discussion (solution)
Request. ServerVariables ["HTTP_REFERER"]
Request. ServerVariables ["HTTP_REFERER"]. ToString (). Contains (Request. ServerVariables ["HTTP_HOST"]. ToString ())
HTTP_REFERER also carries the host address of the website when the external link is in.
Add an IF statement. Then the tostring is parsed to the address, and the counter can be used to determine
Enter HTTP_REFERER in the browser as null.
From the page link, HTTP_REFERER is the url of the page
However, it should be noted that all variables with the HTTP _ prefix are provided by the access party, and the reliability is extremely low.
You can only rely on HTTP_REFERER to judge, although this is not very reliable and can be forged.
Request. ServerVariables ["HTTP_REFERER"]
Request. ServerVariables ["HTTP_REFERER"]. ToString (). Contains (Request. ServerVariables ["HTTP_HOST"]. ToString ())
HTTP_REFERER also carries the host address of the website when the external link is in.
Add an IF statement. Then the tostring is parsed to the address, and the counter can be used to determine
Is there any PHP version of hero?
$ _ SERVER ['http _ referer ']
There seems to be a lot of parameters. Let's take a look.
Leeching is the problem that the landlord said.
Header ("content-type: text/html; charset = utf-8 ");
If (isset ($ _ SERVER ['http _ referer'] [
]) {
// Determine whether $ _ SERVER ['http _ referer' starts with HTTP: // localhost/test /.
// If yes, the website is used. if not, the website is not used,
If (strpos ($ _ SERVER ['http _ referer'], "HTTP: // localhost/test/") = 0 ){
Echo 'This is a site access ';
} Else {
// Jump to the warning page
Header ('Location: warning. php ');
}
} Else {
// Jump to the warning page
Header ('Location: warning. php ');
}
The above code is a piece of anti-leeching code I wrote myself. Your problem can be solved by reading this code. This anti-leeching problem was mentioned in the 84th lecture on the php series video of Chuanzhi podcast Han Shunping. You can get to know more clearly.