Home > Backend Development > PHP Tutorial > Why isn\'t my index.php loading by default in my CentOS Apache/PHP setup?

Why isn\'t my index.php loading by default in my CentOS Apache/PHP setup?

Mary-Kate Olsen
Release: 2024-11-23 11:14:23
Original
1080 people have browsed it

Why isn't my index.php loading by default in my CentOS Apache/PHP setup?

Troubleshoot Index.php Loading Issue in CentOS with Apache and PHP

Question:

Why is my website index.php file not loading by default?

When accessing http://example.com/myapp/, users encounter a "forbidden" error. However, accessing http://example.com/myapp/index.php directly displays the correct content.

Answer:

Configurational Requirement for Index Recognition:

Apache Configuration Fix:

To resolve this issue, configure Apache to recognize index.php as an index file. Follow these steps:

  1. Create a .htaccess file in the web root directory.
  2. Add the following line to the file:
DirectoryIndex index.php
Copy after login

Note:

  • This configuration assumes Apache allows .htaccess files. If it doesn't, modify the setting in Apache's configuration file httpd.conf.
  • For additional information on .htaccess file usage, refer to: http://www.twsc.biz/twsc_hosting_htaccess.php.

The above is the detailed content of Why isn't my index.php loading by default in my CentOS Apache/PHP setup?. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template