Blog, News & Events

How to Enable Directory Browsing for Specific Folders in cPanel

Directory browsing is a web server feature that allows visitors to view the list of files stored in a directory when no index file (like index.html or index.php) is present. While it is generally disabled for security reasons, there are situations where enabling it can be useful—for example, when you want to provide direct access to software downloads, image galleries, or documentation files.

In this guide, we’ll show you how to enable directory browsing for specific folders in your hosting account using .htaccess.

Why Enable Directory Browsing?

Enabling directory browsing can help in scenarios such as:

  • File Sharing: Easily share multiple files without creating individual links.

  • Open Repositories: Make software or documentation accessible in a folder.

  • Media Galleries: Allow users to view/download images, videos, or PDFs directly.

⚠️ Note: Directory browsing can expose sensitive files if not carefully controlled. Always enable it only in specific, non-sensitive directories.

Enabling Directory Browsing with .htaccess

Most hosting providers (including Sternhost) allow you to control directory browsing through the .htaccess file. Here’s how:

Step 1: Access Your File Manager or FTP

  1. Log in to your cPanel or VPS.

  2. Open File Manager or connect via FTP.

  3. Navigate to the specific folder where you want directory browsing enabled.

 

Step 2: Create or Edit .htaccess File

  1. Inside the folder, check if a .htaccess file exists.

    • If it doesn’t, create a new file named .htaccess.

  2. Add the following line to the .htaccess file:

Options +Indexes

This enables directory listing for that folder.

Step 3: Customize the Directory Listing (Optional)

You can also adjust how the listing looks with these directives:

IndexOptions FancyIndexing
IndexOptions SuppressDescription
IndexOptions SuppressHTMLPreamble
  • FancyIndexing – Makes the directory listing look cleaner.

  • SuppressDescription – Removes extra file details like descriptions.

  • SuppressHTMLPreamble – Useful if embedding in custom HTML pages.

 

Step 4: Save and Test

  • Save the .htaccess file.

  • Open your browser and visit the folder’s URL (e.g., https://yourdomain.com/foldername/).

  • You should now see a list of files available for access.

 

How to Disable Directory Browsing Again

If you later decide to remove access, simply update your .htaccess file with:

Options -Indexes

This will disable directory browsing immediately.

Best Practices and Security Tips

  • Never enable browsing for your root or sensitive directories (like /public_html, /wp-admin/, /config/).

  • Create a dedicated folder for files you want to share.

  • Use passwords or authentication if files should only be accessible to specific users.

Enabling directory browsing for specific folders can be a quick way to share files or host an open resource directory on your website. With a simple .htaccess update, you can control exactly where and how this feature is available.

If you’re using Sternhost VPS or cPanel hosting, the process is straightforward and can be implemented in just a few minutes.

Leave a Reply

Your email address will not be published.