Prevent direct access to a certain folder/resource without affecting the application flow

Viewed 34

I'm currently maintaining a website. Our site has a resource which is a .pdf files and a .docx files. Those resources are meant for the internal staff. But recently I found that by searching on google, our resources can be accessed from google.

There's a solution by adding no-index meta tag on the html so that the resources cannot be indexed by google, but I want another layer of protection. I found a solution but I forget where did I get it from. And I have a code like this:

RewriteCond %{REQUEST_FILENAME} ^.*(pdf|doc|docx)$
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?eoffice-bkad.kotabogor\.go.id/ [NC]
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?view.officeapps.live\.com/ [NC]
RewriteRule . - [R=403,L]

That code works, and it return 403 page when accessed if the http referrer is not from the first url. enter image description here

But that code is also giving another problem, the code also blocked <iframe> tag inside the html enter image description here

I'm using Microsoft Office Live preview so that the user can preview the file that they uploaded.

How can I solve this? Any solutions would gladly be welcomed.

Thank you.

0 Answers
Related