Apache configuration disallow access to directory 403

Source: Internet
Author: User
Tags php website

In PHP website development, to ensure the security of website directory files and program code, we must control the access permissions of some directories or files to improve website security, how can we implement this function? In this case, you can configure Apache to prohibit websites from listing website content in the form of directories.

When directory access is not configured in Apache, related directories and file lists are listed when you access http: // localhost. You can modify the Apache configuration file httpd. conf to disable the list of directories/FILES. The method is as follows:


1. Open the apache configuration file "httpd. conf"


2. Find the following parts:

The code is as follows: Copy code

<Directory/>

Options Indexes

AllowOverride None

Order allow, deny

Allow from all

</Directory>

You only need to change Options Indexes to Options None.


Note: depending on the installation package of the PHP running environment, Options Indexes may also be Options Indexes FollowSymLinks, which can be changed to Options None.


Save httpd. conf and restart apache. If not, modify the following configuration:

The code is as follows: Copy code


<Directory "E:/web">

    #

# 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.

    #

   Options none

    #

# 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>

As above: just change the red part.


3. Save httpd. conf, restart Apache, and then access http: // localhost. If no index.html or index exists. when the default files such as php are used, the following error message is returned:

Forbidden

You don't have permission to access/on this server.

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.