Skip to content

How to Fix Index of WordPress

If your WordPress site is showing an “Index of” page instead of your homepage, it’s usually because the index.php file is missing or misconfigured. This guide walks you through identifying and fixing the issue to restore your site and improve security.

Key Takeaways

  • Missing index.php file: The most common cause of “Index of” pages is a missing or corrupted index.php file in your WordPress root directory.
  • Incorrect file permissions: Improper permissions can prevent WordPress from reading essential files, leading to directory listings.
  • Server configuration issues: Apache or Nginx misconfigurations may disable default file handling, exposing folder contents.
  • Security risks: Directory listings expose sensitive files—fixing this improves your site’s security posture.
  • Backup before changes: Always back up your site and database before making file or server modifications.
  • Use default themes as a test: Switching to a default theme like Twenty Twenty-Four can help isolate theme-related issues.
  • Check .htaccess rules: A corrupted or missing .htaccess file can break WordPress routing and cause index issues.

What Does “Index of WordPress” Mean?

When you visit your WordPress site and see a page titled “Index of /” followed by a list of files and folders, it means your web server is displaying the directory contents instead of loading your homepage. This happens when the server can’t find or access the default index file—usually index.php—that tells it which page to load.

This issue isn’t just annoying—it’s a security risk. Visitors (and hackers) can see your file structure, including plugins, themes, and configuration files. Fixing this quickly is essential for both functionality and safety.

In this guide, you’ll learn how to fix the “Index of WordPress” problem step by step, whether you’re using Apache, Nginx, or a managed hosting platform.

Step 1: Check if index.php Exists in the Root Directory

How to Fix Index of WordPress

Visual guide about How to Fix Index of WordPress

Image source: gigxp.com

The first thing to verify is whether the index.php file exists in your WordPress root folder (usually public_html or www).

How to Check via FTP or File Manager

  1. Log in to your hosting account and open the File Manager (cPanel) or connect via FTP (using FileZilla or similar).
  2. Navigate to your WordPress root directory (e.g., public_html).
  3. Look for a file named index.php.

If the file is missing, that’s likely the cause. If it’s there, check its contents—it might be corrupted.

What to Do if index.php Is Missing

If the file is missing, you’ll need to restore it. The good news? You can easily re-create it using the default WordPress index.php code.

  1. Create a new file named index.php in your root directory.
  2. Paste the following code into it:
    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    define('WP_USE_THEMES', true);
    require __DIR__ . '/wp-blog-header.php';
    
  3. Save the file and upload it to your server.

This file tells WordPress to load the correct theme and display your homepage.

Step 2: Verify File and Folder Permissions

Incorrect file permissions can prevent the server from reading index.php, causing it to fall back to directory listing.

Recommended Permissions

  • Folders: 755
  • Files: 644

How to Fix Permissions

Using File Manager or FTP:

  1. Right-click on the index.php file and select “Change Permissions” or “File Permissions.”
  2. Set it to 644.
  3. Do the same for the root folder (set to 755).
  4. Also check wp-config.php and other core files—they should be 644.

> 💡 Tip: Avoid setting permissions to 777—it’s a major security risk.

Step 3: Check Your .htaccess File (Apache Servers)

How to Fix Index of WordPress

Visual guide about How to Fix Index of WordPress

Image source: ediliziastore.it

The .htaccess file controls how Apache handles requests. If it’s missing or corrupted, WordPress may fail to route requests properly.

Locate and Inspect .htaccess

  1. In your root directory, look for a file named .htaccess.
  2. If it’s missing, create a new one.
  3. If it exists, open it and check for proper WordPress rules.

Default WordPress .htaccess Content

Paste this code into your .htaccess file if it’s missing or damaged:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

This ensures all requests are routed through index.php, preventing directory listings.

> 🔗 Related: Learn more about managing WordPress files safely in our guide on how to delete a theme in WordPress.

Step 4: Configure DirectoryIndex in Apache

Apache uses the DirectoryIndex directive to determine which file to load when a directory is accessed. If it’s not set correctly, the server may list files instead of loading index.php.

How to Set DirectoryIndex

You can add this line to your .htaccess file:

DirectoryIndex index.php index.html

This tells Apache to look for index.php first, then index.html if PHP isn’t available.

Alternatively, if you have access to the Apache configuration file (httpd.conf or virtual host file), add:

DirectoryIndex index.php

Then restart Apache:

sudo service apache2 restart

Step 5: Fix Nginx Configuration (If Using Nginx)

Nginx doesn’t use .htaccess. Instead, you must edit the server block configuration.

Edit Your Nginx Site Configuration

Open your site’s config file (usually in /etc/nginx/sites-available/):

sudo nano /etc/nginx/sites-available/yourdomain.com

Ensure the index directive includes index.php:

index index.php index.html index.htm;

Also, verify the location / block includes proper PHP handling:

location / {
    try_files $uri $uri/ /index.php?$args;
}

After saving, test the config and restart Nginx:

sudo nginx -t
sudo service nginx restart

Step 6: Switch to a Default Theme (Troubleshooting)

Sometimes, a corrupted or incompatible theme can prevent WordPress from loading properly, leading to unexpected behavior.

How to Switch Themes via Database

If you can’t access the WordPress dashboard:

  1. Log in to phpMyAdmin via your hosting control panel.
  2. Select your WordPress database.
  3. Find the wp_options table (prefix may vary).
  4. Look for the rows template and stylesheet.
  5. Change both values to twentytwentyfour (or another default theme like twentytwentythree).

Now visit your site. If the homepage loads, the issue was theme-related.

> 🔗 Related: Need help choosing a reliable theme? Check out our guide on the best WordPress theme for SEO and speed.

Step 7: Disable Plugins (If Needed)

A faulty plugin can interfere with WordPress loading. To test:

  1. Rename the plugins folder (in wp-content) to plugins_old via FTP.
  2. Visit your site. If it loads, a plugin was causing the issue.
  3. Rename the folder back and reactivate plugins one by one to find the culprit.

Step 8: Update WordPress Core, Themes, and Plugins

Outdated software can cause compatibility issues. Always keep your site updated.

How to Update Safely

  1. Go to Dashboard > Updates in WordPress.
  2. Update WordPress core, themes, and plugins.
  3. Clear your cache (if using a caching plugin).

> 🔗 Related: Learn how to safely update your theme in our guide on how to update a theme on WordPress.

Troubleshooting Tips

  • Clear browser cache: Sometimes the issue appears fixed but your browser is showing a cached version.
  • Check error logs: Look in your hosting control panel for error logs—they often reveal the root cause.
  • Contact your host: If you’re on shared hosting, your provider may have server-side restrictions. Ask them to check directory indexing settings.
  • Scan for malware: Use a plugin like Wordfence to ensure your site hasn’t been compromised.

Conclusion

Fixing the “Index of WordPress” issue is usually straightforward once you know what to look for. Start by checking for a missing index.php file, then verify permissions, .htaccess rules, and server configuration. Always back up your site before making changes, and test updates carefully.

By following this guide, you’ll not only restore your site’s functionality but also improve its security by preventing unauthorized access to your file structure. Remember: a well-configured WordPress site is a secure and reliable one.