How to Provide Free Access to Certain Types of Files in .htaccess?

In some cases, it is necessary to restrict access to the directory, but leave free access for certain types of files. For example, for files with the pdf extension.

To do this, you can use the following directive in your .htaccess file:

<FilesMatch "\.pdf$">

    Satisfy Any

</FilesMatch>

If you want to block access to certain types of files, use the following directive:

<FilesMatch ".pdf$">

Order Allow,Deny

Deny from all

</FilesMatch>

We also recommend you to read the article Create and configure .htaccess.