Directory indexes control what visitors see when they access a folder on your website without specifying a file. By default, the server displays an index page (like index.html), but if none exists, it can show a list of files in that directory or block access entirely. You can customize these settings to protect your content or improve user navigation.
The Indexes interface in cPanel lets you define how each directory appears to visitors. You can show file listings with details, display only filenames, disable indexing for security, or inherit settings from parent directories.
Understanding Directory Indexes
When someone visits a URL that points to a directory rather than a specific file, the web server needs to decide what to display. If an index file exists (such as index.html, index.php, or default.htm), the server automatically shows that page. If no index file is present, the server can either list the directory contents or display an error message.
Directory indexing becomes important for security and user experience. Publicly listing files in certain directories might expose sensitive information, while in other cases (like download folders), you may want visitors to see available files. OBHost's cPanel interface makes it simple to control these settings for each directory individually.
Configure Directory Settings
Before managing individual directory indexes, you need to set your starting navigation point. This determines which folder the interface opens by default.
To configure your directory settings:
- Click Settings and select one of the following starting locations:
- Home - Begin navigation in the home directory for the domain
- Web Root - Begin navigation in the document root for your primary domain
- Document Root for - Select a specific domain's document root as your starting point
- To make this your default starting location, select the Always open this directory in the future checkbox
- Click Save Changes
Manage Index Settings for Specific Directories
Once you've configured your starting point, you can customize how individual directories display their contents to visitors.
To manage a directory's index settings:
- Navigate to the desired folder using one of these methods:
- Click the folder icon or directory name to enter that folder
- Click Up One Level at the top to move up in the directory tree
- Click Home to return to the home directory
- Click a parent directory name, then click the subdirectory you want to access
- Click Edit under the Actions column next to the directory you want to configure
- Select one of the following indexing options:
- Inherit - The directory uses the same settings as its parent directory. If the parent has no custom settings, system defaults apply
- No Indexing - The server blocks directory listings entirely. Visitors see a "403 Forbidden" error if they try to access the directory without specifying a file
- Show Filename Only - The server displays a simple list of filenames in the directory
- Show Filename and Description - The server shows filenames along with additional details like file size, type, and modification date
- Click Save to apply your changes
Best Practices for Directory Indexing
Choosing the right indexing settings depends on your website's purpose and security requirements. Here are some recommendations:
Disable indexing for sensitive directories. Use the No Indexing option for folders containing configuration files, backups, includes, or any content you don't want publicly accessible. This prevents visitors from browsing these folders even if they guess the directory path.
Enable detailed listings for download directories. If you maintain a public downloads folder or resource library, the Show Filename and Description option helps visitors find files more easily. The additional information about file size and type improves usability.
Use inheritance for consistent site-wide settings. Setting a policy at the root level and using Inherit for subdirectories ensures consistent behavior across your site. You can still override specific directories when needed.
Remember that index files take precedence. Even with directory indexing enabled, if an index.html or similar file exists in the folder, that page displays instead of the file listing. Remove index files from directories where you want listings to appear.
Troubleshooting Common Issues
Directory listing shows when you want a specific page: Verify that your index file has the correct name (index.html, index.php, etc.) and is located in the proper directory. Check file permissions to ensure the server can read the file.
403 Forbidden error appears unexpectedly: Check if indexing is disabled for that directory or a parent directory. Also verify file permissions, as incorrect permissions can trigger forbidden errors even when indexing is enabled.
Changes don't take effect immediately: Browser caching can delay visible changes. Try clearing your browser cache or testing in a private/incognito window. Server-side caching may also require a few minutes to update.
Inherited settings don't work as expected: When using the Inherit option, trace the directory hierarchy to find where settings are actually defined. Remember that system defaults apply if no parent directory has custom settings configured.
Frequently Asked Questions
What happens if I disable indexing but someone knows a specific filename?
Disabling directory indexing only prevents listing the contents of a folder. If someone knows the exact URL of a specific file in that directory, they can still access it directly. To truly protect files, use password protection, move them outside the web root, or configure access restrictions through other security features.
Can I create custom directory listing pages instead of using default formatting?
Yes, you can create custom index files using HTML, PHP, or other web languages. Simply create a file named index.html (or your preferred index filename) in the directory with your custom layout and links. This file will display instead of the automatic directory listing.
How do I show directory listings for some subdirectories but not others?
Navigate to each subdirectory individually and configure its specific settings. You can set the parent directory to show listings, then disable indexing for specific subdirectories that contain sensitive content, or vice versa. Each directory can have independent settings.
Will changing these settings affect my website's SEO?
Directory listings themselves typically don't impact SEO significantly. However, exposed directories can create duplicate content issues if files are accessible through multiple paths. For SEO purposes, it's generally better to create proper navigation pages with index files rather than relying on automatic directory listings.
Need help configuring your directory indexes? The OBHost support team is available 24/7 to assist you. Visit our contact page or email support@obhost.org for personalized guidance with your hosting configuration.