People need help. In short, there is a site where there are files and I need to make sure that these files do not have direct access.

например: http://site.ru/userfile/file.doc 

But I need to make a request with the get parameter

 htp://site.ru/?view=post&path=file.doc 

and in the handler doing so

 $path = "userfile/".$_GET['path']; 

I tried to close access via .htaccess like this. I'm redirecting

 RewriteRule ^userfile/(.*)$ htp://site.ru/ [L,R=301] 

But in this case, the get request from the handler does not work. What do you advise? Is there any way to redirect?

    1 answer 1

    1. Close the file from outsiders in .htaccess
     deny from all 

    Or even put it outside the web directory.

    1. Then in the code we give the file through the headers:
     <?php $filename = 'path/to/file.doc'; // путь к файлу, который будем считывать header('Content-Type: application/msword'); // обязательно поставить нужный контент тайп header('Content-Disposition: attachment; filename=file.doc'); readfile($filename);