Later, I checked some relevant information and found that the window is used in IE. location. href or HTTP_REFERER cannot be obtained. It is really a browser that doesn't understand IE. Many browsers run very well, but it doesn't support it. There is no way at last, PHP can only forge the HTTP_REFERER method or use JS to forge the source.
The HTTP_REFERER submission that can be recognized by IE is a click-triggered event or a Form-submitted request. The following is a summary of the online materials:
<script>function referURL(url){var isIe=(document.all)?true:false;if(isIe) {var linka = document.createElement(‘a');linka.href=url;document.body.appendChild(linka);linka.click();}else window.location = url;}var url=”http://www.jb51.net”;referURL(url);</script>
This method first uses document. all to determine whether the current browser is IE. If yes, a link is generated and The onclick event is automatically executed. If not, JS jump is used. In this way, you can get HTTP_REFERER on the processing page.
This method is tested in IE, Firefox, Safari, and Chrome
2. PHP uses curl to forge IP addresses and generate HTTP Referrer
Referer. php
<? Php $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, "http://mydomain.com/ip.php"); curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('x-FORWARDED-FOR: 8.8.8.8.8 ', 'client-IP: 8.8.8.8 '); // construct IPcurl_setopt ($ ch, CURLOPT_REFERER, "http://www.jb51.net/"); // construct the origin curl_setopt ($ ch, CURLOPT_HEADER, 1 ); $ out = curl_exec ($ ch); curl_close ($ ch); echo $ out;
Ip. php
<?phpfunction getClientIp() {if (!empty($_SERVER["HTTP_CLIENT_IP"]))$ip = $_SERVER["HTTP_CLIENT_IP"];else if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];else if (!empty($_SERVER["REMOTE_ADDR"]))$ip = $_SERVER["REMOTE_ADDR"];else$ip = "err";return $ip;}echo "IP: " . getClientIp() . "<br>";echo "referer: " . $_SERVER["HTTP_REFERER"];