How to fix the WordPress index.php file being outputted

What is the WordPress index.php file? 

The index.php file is part of the WordPress template hierarchy, which is a system used by WordPress to determine which template file should be used to display a specific page or content type. When a visitor requests a page on your website, WordPress checks the template hierarchy to determine which template file to use. If a more specific template file is available, WordPress will use that instead of the index.php file.

In most WordPress themes, the index.php file includes PHP code that retrieves and displays the content of your website’s homepage. This code typically includes calls to WordPress functions that retrieve information from the WordPress database, such as the site title, tagline, and featured content.

While the index.php file is the default template file for your website’s homepage, it is often customised or replaced by a theme’s home.php, front-page.php, or custom-page.php template files. These files are more specific and provide greater control over the appearance and layout of your website’s homepage

Why has the index.php been output and how you can fix it 

Occasionally, you may encounter a WordPress site that outputs the contents of the index.php file directly to the browser.

There are two common reasons for this.

1. It’s usually caused by the permissions set on the index.php file itself. Using the File Manager’s Permissions tool make sure the permissions for this file is set to 640: right-click on index.php > Permissions > Type ‘640

Now try viewing the site in your browser.

2. If changing the permissions hasn’t resolved this, ensure you have a .htaccess file in place inside public_html with the basic WP configuration found here:

If you have a non-standard configuration in your current .htaccess file, make sure to take a copy of this so that you can add it back later if required. After entering the basic WP data, try viewing the site in your browser.

If you’re still seeing the index.php file being output feel free to let our Support Team know.