Monday, May 28, 2012

How do I configure website .htaccess only GoogleDocs Document Viewer can read the files

Open your .htaccess file in the root folder of the website. Add the below set of lines to it.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://202.88.237.162 [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?docs.google.com [NC]
RewriteRule \.(doc)$ - [NC,F,L]


Using the google document embedded viewer
< iframe frameborder="0" src="http://docs.google.com/gview?url=http://http://www.domain.com/file.doc&embedded=true" style="height: 500px; width: 600px;">


If we use the above hotlink protection then the url http://http://www.domain.com/file.doc is not accessible directly. Only Google Document viewer can access the file.

  

Popular Posts