I have the following directory:
examples
file.php
file2.php
helpers
file3.php
secret
.htaccess
index.html
file.json
.gitignore
index.php
README.md
My .htaccess file contains the following:
RewriteEngine On
# Protect the htaccess file
<Files .htaccess>
Order Allow,Deny
Deny from all
</Files>
RewriteRule ^(secret/|*\.json) - [F,L,NC]
<Files "*.json">
Order Allow,Deny
Deny from all
</Files>
When entering the secret folder through the url http://localhost/secret/ it doesn't show me anything (this works fine) but if I enter the .json file inside said folder http://localhost/secret/file.json it does show me shows the content
How can I fix my .htaccess so it doesn't display the contents of that file?
with this you would restrict all *.json
With this rule it hides all the files with the indicated extension (lists are not shown) and if you try to access them by the url it gives you a 403 error, I think it could help you: