Skip to content

How To Restrict Access To Media Uploads Using .htaccess

In this tutorials, I’ll tell you how you can restrict access to media upload formats in your website by using .htaccess file. This trick would allow you to upload your personal files to your hosting and some formats will be restricted from your website, and can only be viewed or downloaded from the file manager/ftp of your hosting.

Add following to your .htaccess file:

# restrict access to uploads directory
<Files ~ ".*\..*">
    Order Allow,Deny
    Deny from all
<FilesMatch "\.(jpg|jpeg|jpe|gif|png|tif|tiff)$">
    Order Deny,Allow
    Allow from all

Only the formats specified in the sixth will be not be restricted. You can add as many formats as you want to sixth line of the code.

1 thought on “How To Restrict Access To Media Uploads Using .htaccess”

Leave a Reply

Your email address will not be published. Required fields are marked *