DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Set a Different Default Index File in Apache

Change Apache’s default directory page from index.html to home.html or another resource using DirectoryIndex, with precise scope, fallback, .htaccess, redirect, and troubleshooting guidance.
WorldApache Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Apache’s DirectoryIndex directive. For example, to serve home.html when someone requests a directory URL such as https://example.com/, add DirectoryIndex home.html in the applicable Apache configuration scope, then reload Apache. The directive can be placed in the server configuration, a virtual-host block, a directory section, or an .htaccess file when that directory permits the Indexes override.

Apache normally looks for index.html. You can replace that name, define an ordered fallback such as index.php index.html, or reset inherited values before defining a completely new list. The browser URL normally remains unchanged because Apache serves the selected file internally.

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 controls Apache’s default page?

The mod_dir module handles directory index requests. When a client requests a directory with a trailing slash, Apache evaluates the DirectoryIndex directive and checks the listed resources in order. The documented default is index.html.

A directory request is different from a request for a specific file. A request for /docs/ invokes directory-index processing; a request for /docs/home.html does not. The index value is a local URL relative to the directory being requested, so DirectoryIndex home.html in the document root refers to the file at the root, while the same directive in a subdirectory refers to that subdirectory’s file.

#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.

The usual result is an internal selection: Apache returns the contents of the index resource while the browser continues to display the directory URL. An external redirect is a separate, optional behavior controlled by DirectoryIndexRedirect.

Choose the configuration scope

Set the directive as close as practical to the directories whose behavior you want to change. Apache HTTP Server 2.4 documentation permits DirectoryIndex in server configuration, virtual-host configuration, directory sections, and .htaccess. The scope determines which sites and directories inherit the setting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Scope Typical use What it affects Important condition
Server configuration A single policy for the server Virtual hosts and directories that inherit it Requires administrator access and a configuration reload
Virtual-host block Different default files for different sites Requests handled by that virtual host Place it in the correct <VirtualHost> block
Directory section A controlled path such as /var/www/site/app That directory and eligible descendants Use the matching filesystem path
.htaccess Per-directory changes without editing the main configuration The directory containing the file and its descendants The server must allow the Indexes override

On managed hosting, a control panel may generate Apache configuration. Its labels and file locations are provider-specific, so the portable method is the Apache directive itself. If a panel overwrites manual changes, use the panel’s supported configuration area or ask the administrator to place the directive in the virtual-host or directory configuration.

Set one replacement index file

To make Apache look for home.html instead of the inherited default, add this line in the desired scope:

DirectoryIndex home.html

In the main server or virtual-host configuration

  1. Open the configuration file that controls the relevant server or virtual host.
  2. Place DirectoryIndex home.html in the global context, or inside the matching <VirtualHost> block.
  3. Save the file and validate the syntax with your distribution’s Apache configuration test command, commonly apachectl configtest or httpd -t.
  4. Reload Apache using the service-management method provided by your operating system. A reload applies the configuration without intentionally stopping existing connections.
  5. Request the directory URL with its trailing slash and verify that the expected page is returned.

The file must be reachable within the requested directory and permitted by the normal filesystem and Apache access rules. If the file is named home.html but actually resides elsewhere, this simple directive will not find it in the location you expect.

In a directory section

A directory section targets a filesystem directory, 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
<Directory "/var/www/site">
    DirectoryIndex home.html
</Directory>

This setting applies to requests mapped to that directory. Use the actual document-root path on your server; a URL path and a filesystem path are not interchangeable.

In .htaccess

Create or edit the .htaccess file in the directory whose index behavior should change:

DirectoryIndex home.html

Apache reads this file for that directory when overrides are enabled. If the server rejects the directive with an “Override not allowed” or similar error, the administrator must permit the Indexes override for the directory, or move the directive into the server, virtual-host, or directory configuration. An .htaccess file cannot grant itself permission to use a directive that the main configuration has prohibited.

Use an ordered fallback list

DirectoryIndex accepts more than one resource. Apache checks the values from left to right and uses the first resource it finds. This is useful during a migration or when a site supports both a dynamic and a static entry point:

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

With that order, a request for the directory uses index.php when it exists; if it does not, Apache checks index.html. Order is therefore a behavior choice, not just a list of acceptable names. Put the preferred resource first and make sure its presence is intentional.

Subdirectory values are relative

If a directory contains landing/home.html, put the directive in the landing directory’s scope:

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)
DirectoryIndex home.html

Alternatively, a parent configuration can name a relative path when that is appropriate for the requested directory, but remember that Apache interprets the value as a local URL relative to the directory request. Test each URL where the directive is inherited; a value that works at the document root may point somewhere different in a child directory.

Replace inherited values instead of appending

Repeated DirectoryIndex directives add entries to the existing list. If a parent scope already defines index.html and a child scope adds home.html, the child may still inherit the parent entry rather than replacing it. To create a clean list, reset the inherited values first:

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

disabled has special control meaning only when it is the sole argument on that directive. In a line such as DirectoryIndex disabled home.html, it is treated as a literal resource name, not as a reset command. Keep the reset and the new list on separate directives.

When to reset

  • Reset when an old index file must never be selected in the target scope.
  • Do not reset merely to add a preferred file if retaining the inherited fallback is desirable.
  • After changing inheritance, test both the target directory and a child directory that may receive the same configuration.

Understand the URL users see

By default, Apache selects the index internally. A request for / or /games/ is answered with the selected file’s content, but the browser normally continues to show the directory URL. This avoids exposing the implementation filename in ordinary navigation.

Redirect the directory request to the index URL

DirectoryIndexRedirect changes the default transparent behavior and issues an external redirect. Apache’s documented modes include temporary, permanent, seeother, and explicit 3xx status codes. A redirect makes the browser request the index resource as a distinct URL, which affects bookmarks, caching, logs, and client-visible navigation.

DirectoryIndexRedirect temporary

Use a redirect only when the URL change is deliberate. It is not required to make home.html load, and it should not be confused with rewriting or with the directory-slash redirect.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Trailing slashes and DirectorySlash

Apache normally normalizes a directory URL that lacks a trailing slash. For example, a request for /games is redirected by DirectorySlash to /games/; directory-index processing then evaluates DirectoryIndex for the slash form.

Leave this redirect enabled unless there is a specific, tested reason to change it. Apache documentation warns that disabling it can expose directory contents in some configurations where mod_autoindex is active. The slash also gives relative links in the index page a predictable base, so turning off normalization can create broken asset and navigation URLs as well as security concerns.

What happens when no index file exists?

Apache checks every configured value in order. If none exists, it does not automatically invent a replacement page. A directory listing can be generated only when the Indexes option is enabled; listing generation is handled by the separate mod_autoindex module.

Possible outcomes

  • An index is found: Apache serves the first matching resource.
  • No index and autoindex enabled: Apache may generate a directory listing, subject to the rest of the server’s access rules.
  • No index and autoindex disabled: Apache returns an error response rather than a listing.
  • The file exists but is inaccessible: Permissions, authorization, or other configuration can prevent successful delivery even though the name matches.

Do not enable directory listings simply to mask a missing index file. If the directory is intended to have a landing page, create the file or correct the directive and keep listings disabled unless users genuinely need them.

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

Complete configuration examples

Static site with one custom entry page

DirectoryIndex home.html

Place this in the site’s virtual-host or document-root scope. A request for the site root checks home.html first. If no fallback is configured and that file is absent, the result follows the no-index behavior described above.

Dynamic application with a static fallback

DirectoryIndex index.php index.html

This makes the application entry point authoritative whenever it is present, while retaining a static page for deployments where the application file has not been installed.

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.

Child directory that must not inherit the parent list

<Directory "/var/www/site/legacy">
    DirectoryIndex disabled
    DirectoryIndex legacy-home.html
</Directory>

The reset prevents a parent’s entries from being considered in this scope. Apache then checks only legacy-home.html for the directory covered by the section, subject to any more-specific configuration.

Per-directory override

# /var/www/site/demo/.htaccess
DirectoryIndex demo.html index.html

Requests for the demo directory check demo.html first, then index.html. This works only when the server’s applicable AllowOverride policy permits the Indexes class.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify a change safely

  1. Confirm the file and path. Check the exact spelling, capitalization, and location of each candidate file. The directive value is a URL-relative name, not an arbitrary filesystem search.
  2. Confirm the active scope. Make sure you edited the virtual host that receives the request and that a more-specific directory configuration is not changing the result.
  3. Check override permission. For .htaccess, verify that Indexes is allowed for that directory. If not, use an administrator-managed configuration scope.
  4. Validate syntax before reloading. Run the Apache configuration test command supplied by your installation. Fix every syntax error before applying a reload.
  5. Reload Apache. Use the service command for the operating system or hosting environment. A restart is not normally required solely for a valid configuration reload.
  6. Test the slash form. Request /directory/, not only /directory/index.html, and inspect the response status and content.
  7. Test the no-slash form. Request /directory to confirm that DirectorySlash produces the expected canonical slash URL.
  8. Test fallback behavior. Temporarily verify which file wins when more than one listed resource exists. Restore the intended files after testing.
  9. Check logs if the result is unexpected. Apache’s error log can reveal an invalid directive, an inaccessible .htaccess, authorization failure, or a missing resource.

Troubleshoot common failures

The browser still shows the old page

First check that the request reaches the expected virtual host and that Apache was successfully reloaded. Then inspect inherited directives: a more-specific scope may define another list, or your new directive may have appended to an old entry rather than replacing it. Use the two-line disabled reset when replacement is required. Also account for client or intermediary caching; test with a fresh request and inspect the response headers before assuming Apache selected the wrong file.

Apache reports that DirectoryIndex is not allowed

This is characteristic of an .htaccess override policy that does not permit the Indexes class. You cannot solve that from the file itself. Ask the administrator to allow the required override for the directory or place the directive in the virtual-host/server configuration.

A directory listing appears instead of the page

None of the configured resources was found, and Indexes is enabled for the directory. Correct the filename or path, add the intended index resource to the list, or disable listing generation if directory contents should not be exposed. Remember that autoindexing is separate from DirectoryIndex.

The requested file exists but is not selected

Check the request path and the directive’s relative location. A directive in a parent directory may be inherited by a child, while a child directive may append or reset values. Verify that the first listed candidate is the file you intend to win and that Apache can read it under the active permissions and authorization rules.

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.

The URL changes unexpectedly

Inspect DirectoryIndexRedirect and other redirect rules. A normal DirectoryIndex selection is internal; an external redirect requires a redirect directive or another rule. Separately, DirectorySlash normally redirects a directory URL without a trailing slash to its slash form.

Security and maintenance considerations

  • Use a specific index file rather than relying on a directory listing when the directory contains private, administrative, backup, or build artifacts.
  • Keep the trailing-slash normalization provided by DirectorySlash unless you have evaluated the consequences for relative URLs and directory exposure.
  • When using multiple candidates, put the trusted, intended entry point first and remove obsolete files that could unexpectedly become active fallbacks.
  • Prefer server or virtual-host configuration when you administer Apache; it is easier to audit centrally and avoids permitting broad .htaccess overrides.
  • Use .htaccess when delegated per-directory control is required, and document the expected override policy so a future administrator does not mistake a permission error for a filename problem.
  • After a migration, test every directory with an index list and confirm that no legacy page is still reachable through inherited configuration.

Decision guide

Goal Recommended directive pattern Why
One custom page everywhere in a site DirectoryIndex home.html Simple single-resource selection in the site’s virtual-host or root directory scope
Prefer an application, then a static page DirectoryIndex index.php index.html Ordered fallback preserves a predictable deployment path
Remove a parent’s inherited choices DirectoryIndex disabled followed by a new directive Resets the list before defining the replacement
Change one delegated directory DirectoryIndex ... in that directory’s .htaccess Limits the change, provided Indexes overrides are allowed
Show the filename in the browser Use DirectoryIndexRedirect deliberately Changes internal selection into an external redirect

Key points to retain

  • DirectoryIndex is the Apache directive for choosing a directory’s default resource.
  • Apache’s documented default is index.html.
  • List multiple names in priority order; the first existing resource is selected.
  • Repeated directives append to inherited values. Reset first with a sole DirectoryIndex disabled directive when you need replacement.
  • .htaccess requires the server to allow the Indexes override.
  • DirectoryIndexRedirect controls whether the selected index is exposed through an external redirect, while DirectorySlash handles missing trailing slashes.
  • A directory listing is supplied by mod_autoindex only when the Indexes option permits it; it is not a substitute for a missing index file by default.

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
PC Slower Than It Used to Be?Free scan - under a minute

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.