开发者

how to hide files in the www directory

Is it possible to hide a folder from the www directory so that the php files will not be seen if you access it through a web browser? I'm doing this becaus开发者_开发知识库e I'm not yet good enough to secure those files and the mysql database that they are manipulating. Or even a trick that would make the web browser not to be able to access the localhost is fine. Please


If you have a directory and you don't want Apache being able to serve any file that's in it, you can create a .htaccess file in that directory, containing :

Deny from all

This will make sure Apache refuses serving any file from that directory -- but they will still be accessible by PHP scripts running from another directory or from the command-line.


If you want Apache to be able to serve the files, but not list the content of the directory when a user accesses that directory without any filename in the URL, you can use this in your .htaccess file :

Options -Indexes

This will disable listing of files inside the directory that contains the .htaccess file -- but will not prevent Apache from serving the files themselves.


Just put the files outside of the document root and include them from there.


A very simple trick if you don't have Apache, hence no access to .htaccess (that sounds like I'm repeating myself), just create a file index.htm or index.html containing NOTHING. Any attempt to access that folder will just show a blank page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜