htacess 盗链问题
我的 htaccess 有此代码
#
# Apache/PHP settings:
#
Options -Indexes
Options +FollowSymLinks
**# NOT WORKING #
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?yourwebdomain.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?friend1domain.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?friend2domain.com(/)?.*$ [NC]
# NOT WORKING #**
# Set the default handler.
DirectoryIndex index.php
# PHP5, Apache 1 and 2
<IfModule mod_php5.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value memory_limit 128M
php_value output_buffering 4096
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
# Modify the RewriteBase if you are using zina in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /zina
# Rewrite current-style URLs of the form 'index.php?p=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]
</IfModule>
如何防止其他站点对我的 mp3 和 jpg 文件进行热链接?
我下载 mp3 的网址结尾为 http://www.domain .com/music/cat_one/band_name/file_mp3_name.mp3?l=12
My htaccess have this code
#
# Apache/PHP settings:
#
Options -Indexes
Options +FollowSymLinks
**# NOT WORKING #
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?yourwebdomain.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?friend1domain.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?friend2domain.com(/)?.*$ [NC]
# NOT WORKING #**
# Set the default handler.
DirectoryIndex index.php
# PHP5, Apache 1 and 2
<IfModule mod_php5.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value memory_limit 128M
php_value output_buffering 4096
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
# Modify the RewriteBase if you are using zina in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /zina
# Rewrite current-style URLs of the form 'index.php?p=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]
</IfModule>
How do i prevent hotlinking from other site for my mp3 and jpg file?
My url for download mp3 end as http://www.domain.com/music/cat_one/band_name/file_mp3_name.mp3?l=12
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 mp3 和 jpg 文件的链接封装在 javscript 函数中。这样,您就没有 html 中的链接,但用户操作(例如单击某个元素)将触发 javascript,从而通过 ie ajax 加载 mp3 或 jpg。
这将阻止大多数热链接,因为其他网站必须模拟用户(这并非不可能,但通常可能不值得付出努力)。
You could encapsulate your links to your mp3 and jpg files inside javscript functions. In this way, you do not have a link in html, but a user action (liking clicking on some element) will trigger a javascript which in turn loads the mp3 or jpg via i.e. ajax.
This will stop most hotlinking because the other website would have to emulate a user (which is not impossible, but most often probably not worth the effort).