Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

How to Disable Directory Listing on Apache and Nginx

Learn the exact Apache and Nginx directives for disabling generated directory listings, where to place them, how index files affect the result, and how to troubleshoot overrides.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache: disable the Indexes option with Options -Indexes in the most specific applicable <Directory>, virtual-host, or .htaccess context. If another directive inherited Indexes, remove that keyword while keeping the other options you need.

Nginx: put autoindex off; in the applicable http, server, or location block. Nginx documents off as the default, but a more-specific block can still turn listings on. After either change, validate the configuration, reload the service, and request a directory that has no index file.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a directory listing is and why it appears

When a browser requests a directory URL such as /assets/, the web server normally looks for an index file. Common examples are index.html, an application front controller, or another filename configured for that site. If no configured index exists, the server has two choices: return an error, or generate a page showing the directory’s files. That generated page is the directory listing often labelled “Index of” in Apache or rendered as an autoindex page in Nginx.

A listing is not the same as a file being publicly reachable. Turning off the listing stops the server from generating a catalogue, but a person who already knows a file’s URL may still retrieve it if routing and file permissions allow access. Use authentication, authorization rules, private storage, or application-level controls when the files themselves must be protected.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Listings can disclose filenames, backup archives, upload directories, source maps, logs, and the layout of a site. Removing that accidental inventory is a sensible hardening step, especially for directories that contain deployment artifacts or user uploads. It does not, however, repair incorrect permissions or remove files that should never be web-accessible.

Quick reference: the setting to change

Server Directive that controls generated listings Where it can be set What to use to disable it Component involved
Apache HTTP Server Indexes in an Options directive <Directory>, virtual-host configuration, or per-directory .htaccess; inherited options also matter Options -Indexes, or remove Indexes from an existing Options line mod_autoindex
Nginx autoindex http, server, or location block autoindex off; ngx_http_autoindex_module

Apache’s automatic index generation is enabled with Options +Indexes; its disabling form is Options -Indexes. Nginx’s syntax is autoindex on | off;, and its documented default is off. In both servers, the setting only has an effect in the configuration context that actually handles the request.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Disable directory listing on Apache

1. Find the configuration that serves the directory

Start by identifying the virtual host and filesystem directory that answer the URL. The setting might be in the active virtual-host file, a broader or narrower <Directory> section, or a per-directory .htaccess file. It can also be inherited from a parent configuration where Indexes was enabled.

Do not edit an example file or an inactive virtual host and assume the change applies. Compare the requested hostname and path with the virtual host’s ServerName, aliases, document root, and directory mappings. For a subdirectory, inspect both the document-root rule and any nested <Directory> or .htaccess rules.

2. Remove or negate the Indexes option

If the applicable configuration contains an enabling line such as:

Options +Indexes

replace it with:

Options -Indexes

If the line enables several options, preserve the others and remove only the listing keyword. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
Options Indexes FollowSymLinks

can become:

Options -Indexes FollowSymLinks

The important part is that the effective options for this directory do not include Indexes. Apache’s FAQ describes the same operation as removing the Indexes keyword from the appropriate Options line.

3. Put the directive in the most specific applicable section

Apache combines configuration from several scopes, and a more-specific section can override a broader setting. A server-wide or parent-directory change may therefore appear to do nothing if a nested rule enables Indexes again. Place the negation in the directory section that maps to the requested path, or in that directory’s allowed .htaccess.

A virtual-host example looks like this (replace the filesystem path with the real document root):

<VirtualHost *:80>
    ServerName example.test
    DocumentRoot /var/www/example

    <Directory /var/www/example>
        Options -Indexes
        DirectoryIndex index.html
        Require all granted
    </Directory>
</VirtualHost>

The DirectoryIndex line is separate from the listing control. Keep an appropriate index file or application entry point so that a normal directory URL still reaches the intended site.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Check the index-file behavior

Apache first looks for a matching DirectoryIndex. When none is found, the Indexes option allows mod_autoindex to return a formatted listing. Disabling Indexes prevents that fallback; it does not create an index file. A directory without an index may consequently return a forbidden or not-found response, depending on the rest of the site’s access rules.

If the directory should show an application page, confirm that its configured index name exists and that the relevant handler can execute it. If it should never be browsable, leaving it without an index while disabling listings is often appropriate, but test the status code expected by your application.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

5. If using .htaccess, confirm that overrides are permitted

Per-directory configuration works only when the server administrator allows the required class of overrides for that path. If Apache returns a server error after adding Options -Indexes, the directory may disallow Options directives in .htaccess. Move the rule into the virtual-host or main configuration, or adjust the directory’s override policy deliberately. Do not hide a syntax or permission problem by deleting the directive and leaving listings enabled.

A minimal per-directory file is:

Options -Indexes

Ensure that a parent .htaccess, an included configuration file, or an application deployment step does not later add Options +Indexes or Options Indexes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

6. Validate, reload, and test Apache

Use the service’s normal configuration test before reloading. On installations that provide the standard Apache utility, a typical check is:

apachectl configtest

Proceed only when the result reports a valid configuration. Reload Apache through your operating system or process manager so workers receive the change; a restart is not normally required solely for this setting. The exact service command varies by distribution and deployment method, so use the procedure used for that installation.

For verification, create or choose a directory that has no configured index file, request its trailing-slash URL, and inspect the response. A generated “Index of” page should no longer be returned. If the application expects a directory index, also request a directory that does contain its normal entry file and confirm that it still loads.

Apache troubleshooting

  • The listing remains: search the active virtual-host and included configuration for another Options Indexes or Options +Indexes. Check nested <Directory> sections and per-directory files, then put Options -Indexes in the most specific applicable context.
  • The rule causes a configuration error: check the spelling and placement of Options -Indexes, and verify that the directory permits the necessary .htaccess override. A syntax test should identify the file and line.
  • The site now returns an error for a directory: disabling a listing does not supply an index. Verify DirectoryIndex, the physical index file, filesystem permissions, and any application rewrite rules.
  • Only one subdirectory behaves differently: inspect that directory for its own .htaccess or a more-specific configuration block. Apache’s specificity rules can make a parent setting ineffective there.
  • Files are still downloadable: that is expected. Listing suppression hides the generated catalogue; it does not deny direct requests. Add access control or move sensitive files outside the web root.

Disable directory listing on Nginx

1. Identify the active server and location

Open the configuration used by the hostname and locate the location that serves the static directory. Check included files as well as the main file; many deployments assemble a server block from fragments. Confirm the request’s path, the root or alias mapping, and whether a regular-expression location takes precedence over the prefix location you edited.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Nginx permits autoindex in http, server, and location contexts. A broad setting can establish a default, while a more-specific location can override it. For a single directory, the location serving that directory is usually the clearest place to make the rule explicit.

2. Set autoindex off;

Add the directive to the applicable block:

server {
    listen 80;
    server_name example.test;
    root /var/www/example;

    location /assets/ {
        autoindex off;
    }
}

If a parent block contains autoindex on;, an explicit autoindex off; in the selected location prevents that location from generating a listing. Remove an unnecessary enabling directive where possible, but retain the explicit setting when it documents the intended behavior for a sensitive path.

Nginx’s documented default is already off. Seeing a listing therefore usually means an included configuration, a parent block, or a more-specific location has enabled it, or that a different server block is handling the request.

3. Confirm the index directive and entry file

Nginx processes a directory request using its index handling. The autoindex module is used for slash-terminated requests when the index module cannot find an index file. Keep the expected file and index directive if the directory should open an application page:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
server {
    root /var/www/example;
    index index.html index.htm;

    location / {
        autoindex off;
    }
}

Do not add an index file merely to conceal an unintended configuration error. Decide whether the path should serve a real entry point or fail without exposing its contents, then configure and test that intended result.

4. Watch location precedence

Nginx does not simply apply the visually nearest line in a file. Its location-selection rules determine which block handles a URI, and the chosen block’s configuration can differ from the one you edited. A regular-expression location, an exact match, or a nested location may serve the request instead of a general prefix block.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

When a listing persists, trace the request to the winning location and inspect every included file for autoindex on;. Put autoindex off; in that winning context or remove the enabling setting at its source.

5. Validate, reload, and test Nginx

Run Nginx’s configuration test before applying a reload:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
nginx -t

The command should report valid syntax and a successful configuration test. Reload Nginx using the service manager, container supervisor, or deployment process that owns the running workers. A reload applies the new configuration without requiring a full stop, provided the test succeeds.

Request a directory that deliberately lacks its configured index file and has a trailing slash. Confirm that Nginx does not return an automatically generated file list. Then test a normal directory containing the site’s index file, plus a known static file, to ensure the change did not break intended delivery.

Nginx troubleshooting

  • A listing still appears: check the actual server block selected for the hostname, all included files, and more-specific locations. Look specifically for autoindex on;.
  • The configuration test fails: inspect the reported file and line for a missing semicolon, a misplaced directive, or an edit in a file not included by the running configuration. Correct the syntax before reloading.
  • The directory now returns an error: verify the index directive, the physical index file, the root or alias path, and filesystem access. Turning off autoindex does not create a fallback page.
  • Only one URI shows a listing: determine which location wins for that URI and place autoindex off; there. A broad setting in http or server does not guarantee the result when a nested location enables the feature.
  • Known files remain reachable: this is normal. Use access controls, deny rules, authentication, or storage outside the public root when direct access must be blocked.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Apache and Nginx: the practical differences

Question Apache HTTP Server Nginx
Primary switch Options -Indexes, or remove Indexes from an existing Options directive autoindex off;
Listing module mod_autoindex ngx_http_autoindex_module
Contexts to inspect <Directory>, virtual host, .htaccess, and inherited Options http, server, and location
What happens when no index exists DirectoryIndex is tried; with Indexes enabled, mod_autoindex can generate a listing Index processing is tried; with autoindex enabled, the autoindex module can generate a listing for a slash-terminated request
Common reason a change appears ineffective A more-specific Options directive or nested .htaccess still enables Indexes A more-specific or differently selected location still enables autoindex, or another server block handles the request
Documented default Depends on the effective Options configuration autoindex off

The syntax differs, but the diagnostic method is the same: identify the handler, find the most specific active configuration, disable the listing switch there, preserve the intended index behavior, validate, reload, and test a directory with no index file.

A safe verification checklist

  1. Choose a controlled test path. Use a directory with no matching index file, or create a temporary test directory outside production content.
  2. Request the canonical directory URL. Include the trailing slash so the server’s directory and index processing is exercised rather than a redirect or application route.
  3. Confirm the generated page is gone. The response must not contain the server’s automatic file list. Record the status code your application intends to return when no index exists.
  4. Test a valid index. Request a directory that contains its normal entry file and verify that it still serves the site or application.
  5. Test a known static file. Listing suppression should not break an asset that is intentionally public.
  6. Check direct access separately. Requesting a guessed filename may still succeed; decide whether that is acceptable and apply authorization or deny rules if it is not.
  7. Recheck after deployment. Configuration generators, container images, and control panels can overwrite hand-edited files. Keep the setting in the source configuration that is actually deployed.

What disabling listings does—and does not—secure

It prevents an automatic index page from advertising the names and paths of files in a directory. That reduces casual discovery and removes one common information leak. It does not encrypt files, authenticate users, sanitize uploads, stop directory traversal vulnerabilities, or override an application route that deliberately serves a file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For sensitive material, use layered controls: store it outside the public document root when possible; require authentication and authorization; restrict filesystem permissions; block backup and temporary extensions; and review logs for unexpected requests. Treat Options -Indexes and autoindex off; as exposure-reduction settings, not as a substitute for access control.

Deployment checklist

  • Identify the exact hostname, URL path, and filesystem directory involved.
  • Find the active Apache <Directory>, virtual-host, or .htaccess context, or the active Nginx server/location context.
  • Remove Apache’s Indexes keyword or set Options -Indexes.
  • Set Nginx’s autoindex off; and check for more-specific autoindex on; directives.
  • Keep or correct the intended DirectoryIndex or Nginx index file.
  • Run apachectl configtest or nginx -t before reloading.
  • Reload through the process manager that owns the service.
  • Request an index-less directory and verify that no generated listing is returned.
  • Test normal index pages, public files, and direct access to anything that must remain private.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.