PHP anti-theft Chain
| The code is as follows |
Copy Code |
|
<?php
Session_Start ();
Session_register (' check ');
$_session[' Check ']=true;
?> |
Check session variables to determine whether to visit the home page. And check that his source page reference (Http_referer) is from the local Web site's Web page.
The method is as follows:
| The code is as follows |
Copy Code |
|
<?php
Session_Start ();
$refs = Parse_url ($_server[' http_referer ')); Decomposition Reference web Information
Check home session and source host are the same
if (!) ( $_session[' check ') | | $refs [' Host ']!= $_server[' http_host '])
Exit
?> |
Note: This can only be a simple anti-theft chain, if a little bit of understanding can be cracked,
Use the server to set up the PHP burglar connection
Apache anti-theft Chain
Modify Httpd.conf
| The code is as follows |
Copy Code |
|
Setenvifnocase Referer "^" local_ref=1
<filesmatch ". (gif|jpg) ">
Order Allow,deny
Allow from Env=local_ref
</FilesMatch> |
If you want to display a "no hotlinking" picture, we can use the mod_rewrite to achieve.
First, add the--enable-rewrite parameter to load the Mod_rewrite module when you install Apache.
Suppose the "Prohibit hotlinking" picture is abc.gif and we can configure this in httpd.conf:
| The code is as follows |
Copy Code |
Rewriteengine on
Rewritecond%{http_referer}!^$
Rewritecond%{http_referer}!^http://(www.)? Www.111cn.net/.*$ [NC]
Rewriterule. (gif|jpg) $ abc.gif [r,l]
DocumentRoot "/usr/local/apache/htdocs"
#设置存放站点html文件的目录.
<directory/>
Options FollowSymLinks
AllowOverride None
</Directory> |
IIS anti-theft Chain
Execute file selection C:rewriterewrite.dll that's it.
Httpd.ini is a configuration file
Picture anti-theft chain Code
| code is as follows |
copy code |
|
[Isapi_ Rewrite]
# 3600 = 1 hour
Cacheclockrate 3600
Repeatlimit #
# Protect Httpd.ini and Httpd.parse.errors Files
# from accessing through HTTP
Rewritecond Host: (. +)
Rewritecond Referer: (?! http://1.*). *
Rewriterule. *. (?: gif|jpg|png|bmp)/force.gif [i,o]
|