How can you deny direct access to files in a directory where I do not want users to access it directly but allow the server/localhost to access because the directory I am trying to avoid direct access contains HTML files that gets output/parsed by PHP.
The listing of the directory looks like this:
template | | +--------> acp | | | +------> acp_index.html | +------> acp_settings.html | +--------> css | | | +------> stylesheet.css | +--------> js | | | +------> scripts.js | +---> index.html +---> login.html +---> etc...
template/acp I need to avoid direct access to files, but localhost/the server should be able to access and parse it.
If i understand this right, you want to keep people out of
template/acp while still allowing the server to access the files?
You could make a
.htaccess and place it in
template/acp, that file should contain the words
deny from all, and just like that, everyone trying to get the file would not be able to, however the server still would be able to via. php or other server side scripting languages...
In php you can use functions like include() or require() to include the file in the php file and even execute php codes from the included file, or read the file with something like fread() or file_get_contents()...
But if your not using any server-side scripting there's no way you can completely avoid direct access to the files if you still need users to be able to see content from them...
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki