Search code examples
apache.htaccessipip-addressgoogle-document-viewer

Server's .htaccess file blocks all traffic outside of intranet, how to enable just google doc embed despite this?


My Server's .htaccess file is written to block every IP address that is not within my University's network. It looks something like this:

order deny,allow
allow from 128.192
allow from 172.16
allow from 172.17
... few more of these...
deny from all

The website I'm working on is currently using a framework that allows users to view/upload pdf/word/ppt/jpg/etc files on the site itself. The viewing functionality is enabled via google doc embed. However, as a result, the server blocks users from seeing the files. I believe it is due to this IP restriction (Once I remove the .htaccess restrictions, the files are viewable again).

e.g. https://docs.google.com/viewer?url=http://www.mywebsite.com/images/1.jpg&embed=true

I have tried enabling a handful of google IP ranges (in .htaccess) I found listed on the internet but have had no success so far. Currently, removing the .htaccess file is not an option. Does anyone have any advice for my situation?

EDIT: solution in comments of approved answer


Solution

  • You could look in the access logs to see which IPs Google is using to access your content.

    It's unlikely that those will stay the same forever, though.

    It's probably best to either move all the affected content to a different subdomain that isn't restricted, or to enable access to the required files for all IPs, on a per-directory or per-file basis, using a <directory> or <files> entry.