Apache settings prohibit access to the website directory (Directory list displays files)

Source: Internet
Author: User
Tags php class regular expression

Go to the apache configuration file httpd. conf and find:

The code is as follows: Copy code

Options Indexes FollowSymLinks

To:

Options FollowSymLinks

In practice, if indexes does not have index.html, the directory structure is displayed.

The code is as follows: Copy code

1. Prohibit access to some files/Directories
Add the Files option to control, for example, do not allow access to Files with the. inc extension, and protect the php class library:
<Files ~ ". Inc $">
Order allow, deny
Deny from all
</Files>

Prohibit access to some specified directories: (you can use <DirectoryMatch> for regular expression matching)
<Directory ~ "^/Var/www/(. +/) * [0-9] {3}">
Order allow, deny
Deny from all
</Directory>

Prohibit by file matching, for example, prohibit all accesses to images:
<FilesMatch .(? I: gif | jpe? G | png) $>
Order allow, deny
Deny from all
</FilesMatch>

Prohibit access to the relative URL path:
<Location/dir/>
Order allow, deny
Deny from all
</Location>

Configuration example:

The code is as follows: Copy code
<Directory "E:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
#
# Possible values for the Options directive are "None", "All ",
# Or any combination:
# 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. Please see
# Http://httpd.apache.org/docs/2.2/mod/core.html#options
# For more information.
# This line can be used only to remove indexes.
# Options Indexes FollowSymLinks
Options FollowSymLinks
#
# AllowOverride controls what directives may be 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>
By default, we recommend that you disable APACHE from browsing directory content.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.