The anti-hotlink code we describe here only focuses on PHP solutions. Of course, if you have server management rights or htaccess file operations, I recommend not to use PHP anti-hotlink code.
Let’s look at the simplest one first
The following is the code implemented in php. xxx.mp3 is the actual address of your music file. When distributing it to the outside world, only the php address is disseminated, and the mp3 address is not disclosed to the outside world
The code is as follows
|
Copy code
|
|||||||||
if(strpos($_SERVER['HTTP_REFERER'], 'qq.com') !== FALSE) {
header('HTTP/1.1 404 Not Found');
} readfile('xxx.mp3');
How to add to the whitelist
Previous article:Introduction to the use of recursive function return values in PHP (ecshop unlimited classification)_PHP tutorial
Next article:Program code for downloading files by opening the page in the browser (php/jsp/java)_PHP tutorial
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Group MySQL results by ID for looping over
I have a table with flight data in mysql. I'm writing a php code that will group and displ...
From 2024-04-06 17:27:56
0
1
406
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|