This article mainly judges the source based on the referfer and jumps to the page to avoid Page access failure. the user experience is poor. for example, I developed a yellow page source code and switched it. Previously set a demo program address: http://www.bitsCN.com and now this domain name needs to be used for other sites, and do not kill the original demo address failure what to do. Then I can use php referer to determine the source. if it is from the address of the webmaster download site, I will transfer it to the site domain name.
I just put the following code in index. php on the http://www.bitsCN.com site so that its access from files.bitsCN.com located to my server frequently used software download http://s.bitsCN.com
You can go to the demo address on this page.
The code is as follows:
$ ReferHost = parse_url ($ _ SERVER ['http _ referer'], PHP_URL_HOST );
$ ValidDomain = 'files .bitsCN.com ';
$ Valid = strstr ($ referHost, $ validDomain) ==$ validDomain;
If (! Empty ($ valid )){
Echo 'script location. href = "http://s.bitsCN.com"; script ';
Exit;
}