Press "Enter" to skip to content

How to block file download outside from Website using .htaccess

0

Hi all!

Below is the code, I am sharing for restricting and blocking the file download from outside of your website.

You can put the below code in .htaccess file to restrict the access.

RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} !^([^@]*)@@https?://\1/.*
RewriteRule \.(gif|jpg|jpeg|png|tif|pdf|wav|wmv|wma|avi|mov|mp4|m4v|mp3|zip?)$ - [F]

This code will block & restrict the access of your file’s access outside from your website.

If you want to block the direct access of any directory, you can put the below code in your .htaccess file.

Options -Indexes

Thanks – Happy Coding!

How to connect MongoDB with PHP CodeIgniter.
Design a christmas tree using Python Turtle Package