search
Homephp教程PHP源码apache的几个设置(目录,权限等)

<script>ec(2);</script>
Apache 实现禁止图片盗链
1、假设充许连结图片的主机域名为:www.demo.com.cn
2、修改httpd.conf
Code:
SetEnvIfNoCase Referer "^http://www.demo.com.cn/" local_ref=1

Order Allow,Deny
Allow from env=local_ref


这个简单的应用不光可以解决图片盗链的问题,稍加修改还可以防止任意文件盗链下载的问题。
 
使用以上的方法当从非指定的主机连结图片时,图片将无法显示,如果希望显示一张“禁止盗链”的图片,我们可以用mod_rewrite 来实现。
 
首先在安装 apache 时要加上 --enable-rewrite 参数加载 mod_rewrite 模组。
 
假设“禁止盗链”的图片为abc.gif,我们在 httpd.conf 中可以这样配置:

Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?demo.com.cn /.*$ [NC]
RewriteRule .(gif|jpg)$ http://www.demo.com.cn/abc.gif [R,L]
++++++++++++++++++++++++++++++++++++++
DocumentRoot "/usr/local/apache/htdocs"
#设置存放站点html文件的目录。
 

Options FollowSymLinks
AllowOverride None

#设置/目录的指令。具体地说明:
Option:定义在目录内所能执行的操作。
 
None:表示只能浏览,
FollowSymLinks:允许页面连接到别处,
ExecCGI:允许执行CGI,
MultiViews:允许看动画或是听音乐之类的操作,
Indexes:允许服务器返回目录的格式化列表,
Includes:允许使用SSI。这些设置可以复选。
 
All:则可以做任何事,但不包括MultiViews。
 
AllowOverride:加None参数表示任何人都可以浏览该目录下的文件。
 
另外的参数有:FileInfo、AuthConfig、Limit。
Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version