WordPress.org

Ready to get started?Download WordPress

Forums

How to allow Google Doc to display hotlinked files? (7 posts)

  1. lasano
    Member
    Posted 2 years ago #

    I have restricted hotlinking my files in wordpress upload folder 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]
    ____________________________________________________

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    This has nothing to do with WordPress itself.

  3. Read http://perishablepress.com/press/2007/11/21/creating-the-ultimate-htaccess-anti-hotlinking-strategy/

    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google\. [NC]

    would be what I would use. No telling what CDN they're using.

  4. lasano
    Member
    Posted 2 years ago #

    Thanks Ipstenu for your reply. I will make a try with this

  5. lasano
    Member
    Posted 2 years ago #

    But this is not working for me
    I used the below code with changes

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomainname.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?google\. [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]
  6. That'll only look for, I think, files named hotlink, but I'm not sure.

    Anyway, that's something you should probably ask on StackExchange. It's not a WP question.

  7. lasano
    Member
    Posted 2 years ago #

    Pitty.
    No one in stackoverflow able to give me a solution
    See my post http://stackoverflow.com/questions/9488339/how-to-allow-google-doc-to-display-hotlinked-files

Topic Closed

This topic has been closed to new replies.

About this Topic