Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk9 min

How to Set Up Apache Virtual Hosts When You Only See the Default Page

Apache shows the default page when the request hostname, destination IP or port does not match a loaded virtual host. This guide covers configuration, DNS and hosts files, HTTPS, apachectl -S, logs and the common failure modes.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If Apache keeps showing its default page, it usually is not ignoring your files. Apache first selects the best-matching IP address and port, then compares the request hostname with each virtual host’s ServerName and ServerAlias. If the hostname does not match, Apache serves the first virtual host listed for that address and port—the default page you are seeing.

Fix the mapping in this order: define an explicit virtual host, make its document root readable, load and validate the file, point DNS (or a local hosts file) at the correct server, request the exact hostname on the correct port, and inspect apachectl -S plus the error log if the result is still wrong.

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.

How Apache chooses a virtual host

Name-based virtual hosting lets several websites share one IP address. For every request, Apache narrows the candidates by the connection’s destination IP and port. It then compares the HTTP Host name with ServerName and ServerAlias in those candidates.

The practical consequence is important: a browser request to http://example.com carries a different hostname from a request to http://203.0.113.10. An IP address cannot match ServerName example.com. If no name matches, Apache uses the first listed virtual host for the selected address and port. That first block is the fallback, which is why a default page appears even when another configuration file exists.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Apache’s 2.4 documentation recommends explicitly listing a ServerName in every name-based virtual host. Relying on an inherited or hostname-derived value can produce surprising matches.

The four values that must agree

  • Request hostname: the domain in the browser URL or HTTP client request.
  • Destination address: the IP address reached after DNS or hosts-file resolution.
  • Port: normally 80 for HTTP and 443 for HTTPS.
  • Virtual-host directives: the block’s ServerName, aliases and listening address.

A correct file cannot win if any of those values point somewhere else.

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

Create a minimal HTTP virtual host

Use one block for each hostname. This is the smallest useful pattern for a site named example.com:

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

Apache’s documentation identifies ServerName and DocumentRoot as the essential directives for a name-based block. ServerAlias adds alternate names, such as the www form. Replace the example domain and path with your own values; do not leave a name in the block that you do not intend to serve.

Prepare the document root

  1. Create the directory named by DocumentRoot, for example /var/www/example.
  2. Place a distinctive test file there, such as an index.html containing the site name. A unique response makes it obvious which block answered.
  3. Check that the Apache service account can traverse every parent directory and read the files. If it cannot, Apache may return a permissions error or an error page even though virtual-host matching is correct.
  4. Read the Apache error log when the directory is missing, unreadable or blocked by a security policy.

Keep the test content simple until routing works. Application rewrites, proxies and frameworks can hide a virtual-host problem behind a second layer of configuration.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Load the file and validate Apache’s configuration

The exact enablement command depends on the operating-system distribution. Some distributions provide helper commands for sites-enabled and sites-available; others load every file included by the main configuration. Do not assume a Debian-specific helper exists on another platform.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Save the block in the location included by your distribution’s Apache configuration.
  2. Use the distribution’s site-enablement mechanism if it has one. Otherwise verify that the main configuration contains an Include directive covering the file.
  3. Validate syntax before reloading. A syntax check prevents a typo from interrupting a running service.
  4. Reload Apache, rather than restarting it unnecessarily, after the check succeeds.
  5. If the reload fails, read the service-manager output and Apache’s error log before changing more files.

A file that is not included has no effect, and a file with a syntax error will not become active merely because it has the right directives.

Make the hostname resolve to this server

Apache does not create DNS records. The name in ServerName must resolve to the server’s address before a public client can reach that virtual host.

Public DNS

Create or update the appropriate DNS record with the provider that serves the domain. Confirm the result with a DNS resolver from a client network. If the record resolves to a different address, that other server will receive the request and its Apache configuration will determine the page. A correct virtual-host file on the intended machine cannot override a DNS record pointing elsewhere.

Local testing with a hosts file

For testing before public DNS is ready, add a line containing the server address followed by every test name, for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
203.0.113.10 example.com www.example.com

Edit the hosts file on the computer that will make the request. This mapping affects only that machine; it does not publish the domain and does not change what other users resolve. Remove or update the entry when the test ends so it does not mask later DNS changes.

Match HTTP and HTTPS separately

A block for port 80 cannot answer a request sent to port 443. Apache first selects the address and port, so an HTTPS URL requires a matching *:443 virtual host and TLS configuration.

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example
    # Certificate and TLS directives required by your platform go here.
</VirtualHost>

Use the certificate, private-key and other TLS directives required by your Apache installation. The certificate must cover the hostname being requested, but certificate validation happens after the connection reaches the HTTPS virtual host; it does not make a port-80 block serve port-443 traffic.

Test the URL scheme explicitly. http://example.com and https://example.com can legitimately select different blocks, document roots or redirect behavior.

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

Use apachectl -S to see what Apache actually loaded

Do not infer the active map from filenames. Run:

apachectl -S

On Windows, use:

httpd.exe -S

Apache documents this command as a dump of parsed addresses and server names. Read it as a routing map, not merely a syntax check.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

What to inspect in the output

  • Address and port: confirm that the block appears under the address and port you are testing, such as *:80 or *:443.
  • Server names: verify that the exact bare domain and any www alias are present.
  • Source filename and line: identify which file supplied each block, especially when several directories contain similarly named files.
  • Order: the first block for an address and port is the fallback for unmatched names.
  • Duplicates: repeated ServerName or ServerAlias values are a warning sign. Apache’s troubleshooting guidance says that only the first listed definition works when names are duplicated.

If the expected block is absent, fix inclusion or enablement before investigating DNS. If it is present under the wrong port, correct the VirtualHost address or test URL. If it is present with a duplicate name, remove the overlap rather than relying on file order.

Test the exact request Apache must match

Use a browser only after you know which name and port are being tested. An HTTP client can make the request explicit and reveal redirects or response headers:

curl -i http://example.com/
curl -i http://www.example.com/
curl -i https://example.com/

Run these from a client whose DNS or hosts file is correct. If you connect directly to an IP while sending a hostname for testing, preserve the intended Host header; otherwise Apache will quite reasonably fall back to the default for that address and port. Also remember that a local hosts-file entry on your workstation does not alter resolution on the Apache server or on another tester’s computer.

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

Use a distinctive response

Put a temporary marker in each document root, such as a page titled “example.com HTTP vhost.” Distinct markers make it possible to distinguish a routing error from stale browser cache, an application redirect or content copied between directories. Remove the marker after verification.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why the default page still appears

Symptom or cause What it means Corrective action
You browse to the server IP The request hostname is an address, not the configured domain. Use the configured hostname, or send an intentional hostname for a controlled test.
The domain resolves to another IP DNS is sending traffic to a different server. Correct the DNS record or test with a hosts entry on the client.
The hosts entry is on the wrong computer Hosts files are local overrides. Add the mapping to the machine making the request.
The block is *:80 but the URL is HTTPS Port 443 has a separate candidate set. Create and load a matching *:443 block with TLS settings.
The file is not included Apache never parsed the block. Place it in an included location or use the platform’s enablement mechanism, then reload.
Duplicate names appear in apachectl -S More than one block claims the same name; the first listed definition wins. Give every hostname one authoritative definition and remove stale aliases.
ServerName is omitted Apache may use an inherited or hostname-derived value that does not match your intent. Set an explicit ServerName in every name-based block.
The map looks correct but content is wrong or unavailable The request reached the block, but the document root, permissions or application generated the response. Check the document path, Apache error log, filesystem permissions and application rules.

Read logs in the right order

When apachectl -S shows the expected name and port, stop rearranging files and inspect the error log first. Apache’s troubleshooting guidance identifies the error log as the first place to look. It can distinguish a missing document root, denied traversal, failed TLS setup, rewrite loop, proxy failure or application error from a virtual-host selection problem.

  • No matching block in the dump: investigate inclusion, syntax validation and enablement.
  • Matching block, 404 response: verify the DocumentRoot and requested path.
  • 403 response: verify directory permissions and any access-control directives.
  • TLS warning or certificate error: inspect the 443 block and certificate coverage.
  • Expected page followed by a redirect: inspect rewrite and application rules; the initial virtual-host match may already be correct.

Change one variable at a time and repeat the same hostname-and-port request. That keeps routing, DNS and application behavior separate.

Name-based versus IP-based virtual hosting

Approach How selection works When it is useful Trade-off
Name-based Several names share an IP; Apache compares the request hostname after selecting the address and port. Most multi-site deployments and local testing. Every name must resolve to the shared address, and each port needs the right block.
IP-based Each site uses a separate IP address, so the destination address selects the site before hostname comparison. Environments that deliberately allocate distinct addresses. Requires additional addresses and still needs correct port and service configuration.

Name-based hosting is generally simpler because multiple domains can share one address. The default-page behavior described here is primarily a name-matching failure: the connection reached Apache, but the requested hostname was not one of the names in the selected address-and-port set.

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.

A repeatable setup and diagnosis checklist

  1. Write one virtual-host block for each intended hostname, with an explicit ServerName, any required aliases and the correct DocumentRoot.
  2. Confirm that the document directory exists and that Apache can read it.
  3. Place the file where the distribution loads Apache configuration, or enable it using that distribution’s mechanism.
  4. Run the platform’s syntax validation and correct every error before reloading.
  5. Reload Apache and confirm that the service remains healthy.
  6. Check DNS from the client, or add a temporary hosts-file mapping on that client.
  7. Request the exact bare and www names, using HTTP or HTTPS as appropriate.
  8. Run apachectl -S (or httpd.exe -S on Windows) and verify address, port, names, source file and order.
  9. Remove duplicate names and stale blocks.
  10. Read the error log when the parsed map is correct but the response is still unexpected.

What not to “fix” by reordering files

Moving a file to the top can change which site receives an unmatched request, but it does not make an unconfigured hostname match. Reordering is appropriate only after you have deliberately chosen the fallback for a specific address and port. First verify the URL hostname, resolved IP, port, loaded configuration and duplicate names. Otherwise you may hide the symptom while leaving requests for misspelled or stale domains pointed at the wrong site.

Final verification before removing the default site

Keep a known-good fallback until the intended site works through every path you support. Verify both configured names, both schemes where applicable, and a request from a client whose DNS behavior matches your users. Once the expected block responds, the default page is no longer evidence of a broken Apache installation; it is simply the fallback for a request that did not match a more specific name.

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 *

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.