CodeIgniter Forums
Prevent access a file in public folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Prevent access a file in public folder (/showthread.php?tid=82619)



Prevent access a file in public folder - septovan.dev - 07-31-2022

I have a json file inside a public folder. I want to restrict the access to the json file from browser but it can be accessed from controller. I do not know how to do it.
For example, json file is placed inside key/foo folder which inside public folder → public/key/foo/bar.json.
I created .htaccess (Deny from all) file in key folder but I still can access bar.json from the browser with this url path http://localhost/key/foo/bar.json
Any help?

Thank you.



RE: Prevent access a file in public folder - superior - 08-02-2022

First, why would you store a secret file in a 'public' folder to restrict access?
Does it contain configurations about something that should be secret?


RE: Prevent access a file in public folder - InsiteFX - 08-03-2022

Please read:

php net - chmod

I would store something like this in an database encrypted.