Home > Operation and Maintenance > Apache > Configure the default home page of the Apache server

Configure the default home page of the Apache server

(*-*)浩
Release: 2020-01-10 15:53:44
Original
14124 people have browsed it

Configure the default home page of the Apache server

1. Modify the default homepage of the Apache server: , the default is to directly access index.html in the htdocs directory, which is configured in conf/httpd.conf.

Find in conf/httpd.conf, its default content is as follows:

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
Copy after login

When accessing the Apache server, it will search here by default For the file, first look for index.php, then index.html. If it cannot be found, it will give an error saying that there is no access permission. According to this rule, you only need to set the file to be displayed in the first place.

2. When accessing the Apache server, the homepage of the specified project will be opened by default:

To access projects under Apache, the access path is: http://localhost:80/ Project name. Sometimes it is required to open the home page of the specified project when accessing http://locahost. Here are two methods.

First method: Put all the files of the project under htdocs, and set the homepage to index.html or index.php. But this will look messy and inconvenient to manage. Therefore not recommended.

Second: Modify the conf/httpd.conf file

The first step is to change the DocumentRoot directory to the project directory, for example My project name is test, and the directory is: D:/Program Files/Apache Software Foundation/PHPWorkspace/test, then my DocumentRoot is:

DocumentRoot "D:/Program Files/Apache Software Foundation/PHPWorkspace/test"
Copy after login

Step 2: Find "This should be changed to whatever you set DocumentRoot to.", set the
<Directory "D:/Program Files/Apache Software Foundation/PHPWorkspace/test">
    Options -Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    #指定访问顺序
    DirectoryIndex index.php index.html
</Directory>
Copy after login

PS: The comment code has been removed. I have added the default access page at the end here, or you can not add it. By default, you will go back to index.php, index.html, etc.

Note: The two paths DocumentRooth and Director involved in these two parts must be consistent. , otherwise an error of not having permission will be reported.

The above is the detailed content of Configure the default home page of the Apache server. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template