.htaccess热链接保护不起作用


.htaccess hotlink protection doesn't work

你能更正&请告诉我。我的问题是我的。htaccess热链接保护不起作用。我在一个共享服务器与。htaccess支持。(SEO友好链接作品)

我的域名类型是http://www.mydomain.p.hthttp://mydomain.p.ht

我的试验的两个来源是:

  1. http://www.htaccesstools.com/hotlink-protection/
  2. stackoverflow

我没有忘记用我的实域替换mydomain

我. htaccess

RewriteEngine On
RewriteBase /
# hotlink protection
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www'.)?mydomain.p.ht [NC]
RewriteRule '.(jpg|jpeg|png|gif|css)$ - [NC,F,L]
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# File caching is another famous approach in optimizing website loading time
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
#SEO friendly linking
...
...

我也试过

<标题> 1
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www'.)?mydomain.p.ht [NC]
RewriteRule '.(flv)$ - [NC,F,L]
<标题> 2 h1> div class="answers">

你的方法是正确的,工作良好。由于您为这些文件启用了缓存,因此http://htaccesstools.com/test-hotlink-protection很可能会显示映像的缓存快照。如果你真的想测试它,在本地主机或mydomain.p.ht主机以外的其他主机上创建一个html文件,并包含以下行(将/images/home.gif '替换为实际gif文件的路径):

<img border="0" src="http://mydomain.p.ht/images/home.gif">

看看图像是否显示在浏览器中。如果您在执行此操作时打开了Firbug网络选项卡,您应该会看到上面图像的禁止403状态