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

Configure the default home page of the Apache server

(*-*)浩
(*-*)浩 Original
2020-01-10 15:53:44 13775browse

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 794ea01c23a0d5c1a7b2f169e4879de9 in conf/httpd.conf, its default content is as follows:

 DirectoryIndex index.php index.html 

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"

Step 2: Find "This should be changed to whatever you set DocumentRoot to.", set the
 Options -Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all #指定访问顺序 DirectoryIndex index.php index.html 

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!

Statement:
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