View files in a folder behind the webroot

Hi everybody,

i have a upload folder on the root from yii2.

e.g. \yii2\uploads

This works fine, and i can also download files from there. But no i will preview a pdf-file in a iframe. How can i access the file with an url? Is that possible?

I found a solution on
https://stackoverflow.com/questions/46494061/yii2-how-to-access-a-folder-in-root-folder

But this not work. I can’t access the file. This is my .htaccess file in the yii root folder:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !/(uploads)/

I don’t know if this is the right way.

Thanks for help…

I have chosen a different path. My concern is that the documents in question are not freely available in a folder on the net.

Therefore, I now proceed in such a way that I save the content of the files as a BLOB in my database and load them from there for the view and display them with . Works flawlessly.