Preventing the ‘Index Of’ page in .htaccess Updated on June 12, 2025 by Scott Mitchell 1 Minutes, 6 Seconds to Read When working with your site there may be many files or folders. Ideally, most folders should have an index page of some sort. For our servers, they should be one of three names: index.htm, index.html, and index.php. As long as the folder contains at least one file with one of these names, it will display on the screen. If, however a folder does not contain one of these files, then it will simply display a list of all files and folders contained within. This is the default behavior, but you can also change it within the .htaccess file. This article will guide you on how to prevent the list showing, even if the index pages are not in the folder. How to Prevent the Index Of page Log into your cPanel dashboard. Once in the cPanel, click on the File Manager icon, located in the Files category. Locate the .htaccess file and open it for editing. At the top of the file, add the following code: Options -Indexes Save and close the file. Now when someone visits a directory or folder that has no index file, it will receive a 403 Forbidden error instead of seeing a list of the directory’s contents. The 403 error indicates the visitor does not have access permissions to view that area. Professional Websites Without the Tech Headaches Our team will build a beautiful WordPress site and take care of updates, security, and maintenance – so you can focus on running your business. Let Us Handle It for You Share this Article Related Articles AWStats: View Statistics About Your Website Traffic MySQL Error 1064: You Have an Error in Your SQL Syntax MySQL Error 1044 Access Denied Troubleshooting: Fixing the “localhost Refused to Connect” Error HTTP Error Codes: What They Mean and How to Fix Them How to Fix the 504 Gateway Timeout Error 500 Internal Server Error How To Create a PHP Redirect (301, 302, and Dynamic Redirect Examples) Connect to SFTP for Shared Hosting Accounts Using FileZilla FTP Basics for Dedicated Servers