How to Load index.php by Default in Apache
If you encounter a "forbidden" error when accessing your website's root directory (e.g., http://example.com/myapp/) but can successfully access the index.php file directly (e.g., http://example.com/myapp/index.php), you may encounter an issue with how Apache handles index files.
To resolve this, Apache needs to be configured to recognize index.php as an index file. The simplest method is to create a .htaccess file in your web root with the following line:
DirectoryIndex index.php
This instructs Apache to treat index.php as an index file, making it the default page to load when the directory URL is accessed. Here's a detailed step-by-step guide:
Note that Apache may need to be configured to allow .htaccess files (e.g., by enabling AllowOverride in httpd.conf).
The above is the detailed content of How to Make Apache Serve index.php as the Default Page?. For more information, please follow other related articles on the PHP Chinese website!