In the PHP website development, in order to let the website directory file and the program code security consideration, we must to some directories or the file Access Authority control, enhances the website the security, then how can we realize this function? Apache can then be configured to prevent Web sites from listing site content in the form of a directory.
When there is no configuration in Apache to prohibit directory access, when you access http://localhost will list the relevant directories and file lists, we can modify the Apache profile httpd.conf to prevent listing directory/file list, the following methods:
1, open the Apache configuration file "httpd.conf"
2, find the following parts
The code is as follows |
|
<directory/> Options Indexes AllowOverride None Order Allow,deny Allow from all </Directory> |
Simply modify the options indexes to the options none.
Note: According to the PHP operating environment installation package is different, options Indexes may also be options Indexes followsymlinks, together with options none can be.
Save httpd.conf and restart Apache. If this does not work, continue to modify the following configuration:
code is as follows |
&nbs P; |
<directory "E:/web" # # Possible values for the Options directive are ' None ', ' all ', # or any comb Ination of: # Indexes Includes followsymlinks symlinksifownermatch execcgi MultiViews # # Note that ' MultiViews ' must be named *explicitly*---' Options All " # doesn ' t give it to you. # # The Options directive is both complicated and important. # http://httpd.apache.org/docs/2.2/mod/core.html#options # For more information. # options none # # allowoverride Controls what directives may is placed in. htaccess files. # It can be ' all ', ' None ', or any combination of the keywords: # Options FileInfo authconfig Limit # allowoverride None # # Controls who can get stuff from this server. # Order Allow,deny Allow from all </directory> |
As above: The red part of the inside, and then changed to the line.
3, save httpd.conf, and restart Apache, and then visit http://localhost, if there is no index.html or index.php these default files, will report Apache HTTP 403 prohibit access to error messages:
Forbidden
You don ' t have permission to access/on this server.