We have a directory on our website, ./content/
, that contains a bunch of subdirectories, each of which contain their own subdirectories, etc etc. In these subdirectories there are also a lot of .PDF docs that we need to prevent someone from being able to directly access, say by going directly to example.com/content/myfile.pdf.
We have the files referenced throughout our site and being loaded through Mozilla's PDF.js library so, obviously, we need to be able to have our PHP/HTML/JS files to be able to access them, but ONLY from within our domain.
I tried creating an .htaccess file both at our domain root and in the content folder to limit access but I'm still able to directly access them. Here's the .htaccess contents:
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^$ https://www.example.com/* [R=301,L]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC]
RewriteRule ^_content/[^.]+\.(jpe?g|gif|bmp|png|pdf)$ - [F,NC]
</IfModule>
Thanks in advance.