Search code examples
.htaccessdocumentviewerhotlinking

How to allow Google Doc to display hotlinked files?


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]


Solution

  • 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