htacess 盗链问题

发布于 2024-09-14 11:15:58 字数 1437 浏览 3 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感性 2024-09-21 11:15:58

您可以将 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文