# Enabling and disabling directory index listings via .htaccess

> Turn directory index listings on or off for a folder on your website using a simple .htaccess directive.

Source: https://helpcenter.ruachost.com/developers/web-servers/enabling-and-disabling-directory-index-listings-via-htaccess/

By default, Apache servers on **ruachost.com** do not display directory listings for security reasons. Instead, visitors see a **403 Forbidden** error if a directory has no index page. You can override this behavior using the `.htaccess` file.

## Why Control Directory Index Listings?

- **Enable listings** when you want visitors to browse files in a directory (e.g., downloads).
- **Disable listings** to prevent unauthorized users from seeing file structures.
- Provides flexibility for developers and administrators.

## Enabling Directory Index Listings

To allow visitors to see file listings in a directory:

1. Open or create the `.htaccess` file in the directory.
2. Add the following directive:

   ```
   Options +Indexes
   ```
3. Save the file.
4. Reload the site — the directory will now display a list of files.

???? You can also enable **fancy indexing** (shows filenames, sizes, and modification dates):

```
IndexOptions +FancyIndexing
```

## Disabling Directory Index Listings

Directory listings are disabled by default, but if you previously enabled them, you can turn them off:

1. Open the `.htaccess` file.
2. Add the following directive:

   ```
   Options -Indexes
   ```
3. Save the file.
4. Visitors will now see a **403 Forbidden** error instead of file listings.

 To disable fancy indexing but keep standard indexing:

```
IndexOptions -FancyIndexing
```

> **Important Notes:**
- You can enable listings site‑wide by placing `Options +Indexes` in the root `.htaccess` file.
- For security reasons, enabling listings globally is **not recommended**.
- Subdirectories inherit settings unless they have their own `.htaccess` file.
- Always test changes after editing `.htaccess` to avoid misconfigurations.
