Deny access to particular file or extension using .htaccess
- Friday, 25 March 2016 22:13
- Aadil P.
While updating all of my artwork developed for clients to my server, I ended up uploading the .psd files as well. However, I wanted to deny access to the “.psd” sources and the royalty free artwork I had purchased and downloaded from graphic download sites.
While googling a possible solution I ended up on this StackOverflow question How to deny access to a file in .htaccess
Ended up using the second part of the suggested/selected answer on the particular question above – the rewrite rule in .htaccess. So here is what I added to my .htaccess.
RewriteRule /?\.psd$ - [F,L]
RewriteRule /?\.hide$ - [F,L]
*For my royalty free artwork (jpegs and pngs), I appended those files with .hide extension to hide them