Home > Backend Development > PHP Tutorial > Apache .htaccess 怎么阻止静态资源被直接访问(如图片或CSS)而必须要求在被信任的域名上的页面中引用?

Apache .htaccess 怎么阻止静态资源被直接访问(如图片或CSS)而必须要求在被信任的域名上的页面中引用?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:27:18
Original
2494 people have browsed it

当检测到盗链时不返回静态资源。 (比如a.jpg只有当被mydomain.com和baidu.com上的页面引用时正常输出而不能被直接访问或在其他域名上引用)

回复内容:

当检测到盗链时不返回静态资源。 (比如a.jpg只有当被mydomain.com和baidu.com上的页面引用时正常输出而不能被直接访问或在其他域名上引用)

<code>RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !mydomain.com [NC]
RewriteCond %{HTTP_REFERER} !baidu.com [NC]
RewriteRule .(png|jpg)$ /bad.gif [R,NC,L]</code>
Copy after login

具体可以看看htaccess的使用说明,不是来着这两个域名的请求(png或者jpg),将被重定向到bad.gif

Related labels:
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 Issues
Apache automatically stops
From 1970-01-01 08:00:00
0
0
0
apache restart failed
From 1970-01-01 08:00:00
0
0
0
apache error
From 1970-01-01 08:00:00
0
0
0
How apache logs
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template