Thursday, November 5, 2020

Deny access to files with Specific extension in Apache

 Description: Here I have explain how to deny specific extension in Apache using .htaccess file or httpd.conf file

Procedure:

  • For the demo purpose I have blocked "mp3, avi, flv, pdf " extensions. Open .htaccess or httpd.conf file and use Files Directives to block extension 
  • Open httpd configuration file using below command

# vi /etc/httpd/conf/httpd.conf

  • Add below Files Directives under virtual host then save file. 

<Files ~ "\.(mp3|avi|flv|pdf)$">

Deny from all

</Files> 

  • Restart httpd service and verify by access pdf file in URL

No comments:

Post a Comment