How to allow pdf files in .htaccess?

by mallory_cormier , in category: Third Party Scripts , 5 months ago

How to allow pdf files in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by scotty_walker , 5 months ago

@mallory_cormier 

To allow PDF files in .htaccess, you need to add a rule that allows access to files with a .pdf extension. Here is how you can do it:

  1. Open your website's .htaccess file using a text editor or FTP client.
  2. Add the following line to the .htaccess file:
1
2
3
<FilesMatch ".(pdf)$">
   Allow from all
</FilesMatch>


This rule specifies that all files with a .pdf extension should be allowed access to everyone. If you want to restrict access to certain users or deny access to specific IP addresses, you can modify the rule accordingly.

  1. Save the .htaccess file and upload it to your server.


After adding this rule to your .htaccess file, PDF files should now be accessible to users on your website.