How to make file in my website only accessible by serverside?

Hi
create an .htaccess file with this content:

Require all denied

this will create 403

But first, you should move that JSON to some subfolder where the .htaccess file will be

because if you put it on root (.htaccess file)
probably some basic things from your website will not work online


if you just want to hide the contents of the folders (but it will be accessible to everyone who knows the path)
then you can use this

# Disable Directory Listings in this Directory and Subdirectories
Options -Indexes

and it is recommended !
and do that by putting the .htaccess file with this content on the root

5 Likes