문제

I have restricted hotlinking my files in using htaccess. But I need those files to be displayed in Google Doc Viewer. In htaccess I allow Google Docs to hotlink my files, but it is not working. Please help me in this Below is the code I used in my htaccess file

RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomainname.com/ [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?docs.google.com [NC] RewriteCond %{REQUEST_URI} !hotlink\.(gif|png|jpg|doc|ppt|xls|pdf|html|htm|xlsx|docx|pptx|swf) [NC] RewriteRule .*\.(gif|png|jpg|doc|ppt|xls|pdf|html|htm|xlsx|docx|pptx|swf)$ http://mydomainname.com/ [NC]

도움이 되었습니까?

해결책

Oliver S is correct, but maybe the name of the user agent is changed now.. I tried

RewriteCond %{HTTP_USER_AGENT} !(.*Google.*)

And it worked perfectly

다른 팁

Using the referrer from https urls will probably not be very successful. Note also that the remote in the googledocs are not fetched by the browser from your server, but from a server process at google.

I had the same problem and the trick I found was to allow a specific User-Agent:

RewriteCond %{HTTP_USER_AGENT} !(.*Feedfetcher-Google.*)

Of course it is easily spoofable, but in "normal usage" your hotlink protection will still work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top