如果有人试图直接访问我的文件或试图将我的文件包含在第三方网站/跨网站中,我想给出403错误给特定的扩展名。
例子:
假设example.com是我的网站,它有一个图像文件happy.png,所以如果有人访问example.com/playy.png,它应该显示403错误,而且它也不应该被用于任何其他领域,如<img src="http://example.com/happy.png" />,除了我的域example.com。只有我的域名才能使用我的资产。
i想否认txt,png,jpg,jpeg,ico,css,js等
.htaccess代码:
<FilesMatch ".txt", "png", "css", "js">
Order Allow,Deny
Deny from All
</FilesMatch>或
<FilesMatch ".(htaccess|htpasswd|ini|psd|log|sh)$">
Order Allow,Deny
Deny from all
</FilesMatch>我的密码怎么了?为什么它不像我想的那样起作用?
发布于 2021-12-28 20:20:58
使用这个
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www\.example\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.example\.com$ [NC]
RewriteRule .*\.(txt|ico|jpg|jpeg|gif|png|bmp|js|css)$ - [F,NC,L]或
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteRule \.(gif|jpeg|js|css)$ - [F,NC,L]https://stackoverflow.com/questions/70511790
复制相似问题