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<IfModule dir_module> DirectoryIndex index.php index.html </IfModule>
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"
<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>
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!