Welcome Guest, Not a member yet? Register   Sign In
Prevent access a file in public folder

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.

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?

Please read:

php net - chmod

I would store something like this in an database encrypted.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB