Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween 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

Domain Not Pointing to Your Apache VirtualHost Directory? How to Fix It

A practical, layer-by-layer guide to fixing domains that resolve to the wrong Apache virtual host or serve the wrong DocumentRoot.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If a domain shows Apache’s default page or another site, changing DocumentRoot may not be the right first move. Trace the request in order: DNS must return the server’s address, the request must reach the intended port, Apache must match the exact hostname to the intended virtual host, and that virtual host must point to a readable directory.

Use apachectl -t to catch syntax errors and apachectl -S to see Apache’s parsed virtual-host map. Those two checks, combined with a log entry and a request to a deliberately nonexistent URL, usually identify the failing layer without guesswork.

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.

Understand what Apache is (and is not) selecting

A browser request contains several values that Apache evaluates separately:

Layer What is evaluated Typical failure Visible result
DNS The domain and aliases resolve to an IP address. An old A record, wrong AAAA record, or missing CNAME. The request reaches another server, times out, or never reaches Apache.
Listener The destination IP and TCP port, normally 80 for HTTP or 443 for HTTPS. The site is configured only on port 80, while the browser uses 443. HTTP works but HTTPS shows a different site, certificate, or redirect.
Hostname matching The HTTP Host value is compared with ServerName and ServerAlias in virtual hosts for that address and port. The alias is absent, the file is not enabled, or the request reached a different IP. Apache’s default page or another customer’s virtual host appears.
Filesystem mapping The selected virtual host’s absolute DocumentRoot, URL path, and DirectoryIndex. The directory does not exist, has the wrong content, or cannot be read by Apache. A 404, 403, blank directory response, or an application error.

Apache’s name-based hosting logic first narrows the candidates by destination address and port, then compares the hostname. Once a virtual host is selected, Apache appends the URL path to that host’s DocumentRoot. A request for / is handled through DirectoryIndex, commonly an index HTML or PHP 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.

Virtual-host configuration does not publish DNS. An Apache server can contain a perfect ServerName and still never receive traffic for that name until the DNS provider points the name at the server.

Step 1: verify DNS before changing Apache

Check the apex name and every alias separately. A common partial fix is to point example.com at the server while leaving www.example.com at an old address.

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

Resolve each name from a client

Run one of these commands on the machine that is showing the wrong site:

dig +short example.com
dig +short www.example.com
nslookup example.com
nslookup www.example.com

Compare the returned IPv4 address with the server’s public address. If the domain has an AAAA record, compare the returned IPv6 address as well. A browser that has working IPv6 connectivity can follow a wrong AAAA record even when the A record is correct, making the problem appear intermittent or location-dependent.

Correct the records at the DNS provider

  • Use an A record for an IPv4 address and an AAAA record for an IPv6 address that is actually configured on this server.
  • Use a CNAME for an alias only when the DNS provider and your zone design call for it; verify the final address after the CNAME is followed.
  • Point www, regional names, and application subdomains individually. Apache aliases do not create DNS records.
  • After saving a record, wait for its stated TTL. Different resolvers can show the old answer until that cache period expires.

For local-only testing, add a line to the hosts file on the client machine, such as 203.0.113.10 example.com www.example.com, using the server’s real address in place of the example address. A hosts-file entry affects only that machine; it does not publish the name to other users or override public DNS.

Prove whether DNS is the problem

To test Apache without relying on public DNS, send a request to the server address while supplying the intended hostname:

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
curl -H 'Host: example.com' http://127.0.0.1/

Run that command on the server for an HTTP virtual host. If it returns the expected site locally but a normal browser request does not, investigate DNS, the public route, or a proxy in front of Apache rather than changing DocumentRoot.

Step 2: check the IP address and port Apache is serving

Apache maintains separate virtual-host sets for each address and port. A correct <VirtualHost *:80> block has no effect on a request arriving at port 443. Conversely, fixing only the HTTPS block does not change plain HTTP.

Check both protocols

  • Request http://example.com/ and note the status, Location header, and page identity.
  • Request https://example.com/ separately. Confirm that the certificate belongs to the intended name and that the page comes from the intended directory.
  • If one protocol is meant to redirect to the other, make that redirect explicit in the port-80 virtual host and keep a deliberate port-443 virtual host for the final hostname.

On a server with several network addresses, an explicit address in <VirtualHost> must match the address receiving traffic. A wildcard such as *:80 covers all local IPv4 addresses for that port, subject to the rest of the Apache configuration.

Step 3: make the hostname match exactly

Each virtual host should have at least a ServerName and an absolute DocumentRoot. Put the canonical hostname in ServerName and every additional spelling that should serve the same content in ServerAlias.

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

Minimal HTTP configuration

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/example-error.log
CustomLog ${APACHE_LOG_DIR}/example-access.log combined
</VirtualHost>

The directory in DocumentRoot is an absolute filesystem path, not a URL and not a path relative to the configuration file. If the site is meant to answer only for www.example.com, do not assume that the apex name will match automatically; list it or create a separate intentional redirect.

Create the corresponding HTTPS host

When HTTPS serves the site directly, create a port-443 block with the same names and an intentional document root:

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)
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
SSLEngine on
SSLCertificateFile /etc/ssl/example/fullchain.pem
SSLCertificateKeyFile /etc/ssl/example/privkey.pem
ErrorLog ${APACHE_LOG_DIR}/example-ssl-error.log
CustomLog ${APACHE_LOG_DIR}/example-ssl-access.log combined
</VirtualHost>
</IfModule>

The certificate paths in this example must point to files that exist on your server. If port 443 is intended only to redirect elsewhere, configure that redirect deliberately; leaving the HTTPS name unmatched allows another port-443 virtual host to answer.

Step 4: confirm Apache loaded the file

A correctly written file does nothing if it is outside Apache’s included configuration or was never enabled. First test syntax, then inspect the parsed map:

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.
sudo apachectl -t
sudo apachectl -S

The first command should report that the syntax is OK. Do not reload after a failed test. The second command prints the virtual hosts Apache actually parsed, including the address and port, the default host for each pair, and the source file and line where each host was defined.

Interpret apachectl -S

  • Confirm that both *:80 and *:443 appear when both protocols are required.
  • Confirm that the intended file is listed. If it is absent, check the distribution’s include directories and site-enabling mechanism.
  • Confirm that the expected ServerName and aliases are attached to the right address and port.
  • Look for another virtual host claiming the same name or an earlier host that has unintentionally become the default.

On Windows, run the equivalent command with the Apache binary, for example httpd.exe -S, from the installation’s bin directory. The output serves the same purpose: it shows Apache’s parsed, not merely edited, configuration.

Enable and reload using your distribution’s method

Debian- and Ubuntu-style installations commonly keep site files under /etc/apache2/sites-available and enable them with a2ensite; other distributions commonly include files from an Apache configuration directory directly. Use the mechanism already defined by your installation, then run the syntax test and parsed-map check again.

sudo apachectl -t
sudo systemctl reload apache2

Some systems use the service name httpd instead of apache2. A reload applies a valid configuration without unnecessarily dropping established connections. If the reload reports an error, correct that error and test again before attempting another reload.

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

Why the Apache default page appears

An unmatched hostname is served by the first name-based virtual host for that address and port. The default page therefore does not prove that the requested directory is wrong. It often means Apache never selected the virtual host you edited.

Common causes

  • The site file is not enabled or is not included.
  • ServerAlias www.example.com (or another required spelling) is missing.
  • The browser resolved the name to another server address.
  • An incorrect AAAA record sent the browser over IPv6.
  • The request arrived on 443, but only a port-80 virtual host exists.
  • The hostname contains a spelling difference, such as an extra label or a different public suffix.
  • A load balancer or reverse proxy forwarded a different Host value than the browser sent.
  • Two files define overlapping hosts and the earlier one is answering first.

Use apachectl -S to distinguish an unmatched name from a filesystem problem. If the intended host is not in the output for the relevant port, changing its directory cannot affect the request.

Separate virtual-host selection from DocumentRoot errors

Once you know the correct virtual host answered, inspect its filesystem mapping.

Check the directory and index

  • Verify that the exact DocumentRoot directory exists.
  • Place a temporary, distinctive test file such as vhost-check.txt in that directory and request /vhost-check.txt.
  • For the root URL, verify that the expected file name is included in DirectoryIndex, for example index.html or index.php.
  • Ensure the Apache account can traverse every parent directory and read the files. A missing execute permission on a parent directory can produce a 403 even when the files themselves look readable.

Apache combines the URL path with the selected root. A request for /images/logo.png maps beneath that root; it does not search every virtual host for a matching file.

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

Use the status code as a clue

Response Most likely layer Next check
Default Apache page or another site DNS, port, hostname match, or load order. Resolve the name and inspect apachectl -S.
404 from the expected site Correct host selected, but URL-to-file mapping or application routing is wrong. Check DocumentRoot, the requested path, rewrites, and the application’s route.
403 Forbidden Directory permissions, access rules, or a missing index when directory listing is disabled. Read the error log and verify traversal and read permissions.
Certificate warning or wrong certificate Port-443 selection or TLS certificate configuration. Inspect the 443 hosts and certificate directives; do not diagnose this from the port-80 block.
Redirect to an unexpected hostname A redirect in the selected virtual host or application, or the wrong host answered first. Use curl -I and inspect the Location header and logs.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use logs and a deliberately bad URL

Watch the access and error logs for the virtual host while making a request. The access log confirms whether Apache received the request and records the status; the error log often explains a missing file, permission denial, rewrite failure, or certificate problem.

To identify which configuration handled a request, request a path that cannot exist, such as:

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.
curl -i http://example.com/this-path-should-not-exist-9f3a

Apache’s troubleshooting guidance recommends this technique because the response and log entry can be correlated without confusing an application-generated home page with Apache’s own response. Give the temporary test path a unique marker, inspect the result, and remove any temporary marker file or response header afterward.

Test a virtual host locally with an explicit Host header

curl -i -H 'Host: example.com' http://127.0.0.1/this-path-should-not-exist-9f3a
curl -i -H 'Host: www.example.com' http://127.0.0.1/this-path-should-not-exist-9f3a

If those commands produce different branded responses, Apache is matching the names as configured. If both produce the same default response, inspect the parsed map and enabled files. For HTTPS, test the public name against the server address with a resolver override when appropriate, because TLS hostname selection and certificate validation are part of the 443 path.

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

Fixes for the most common combinations

The apex works, but www shows the default page

  1. Resolve both names and compare their addresses.
  2. Create or correct the DNS record for www.
  3. Add ServerAlias www.example.com to the port-80 and port-443 hosts, or create an explicit redirect host.
  4. Run apachectl -t and apachectl -S, reload, and test both names.

HTTP works, but HTTPS serves another site

  1. Resolve the name and verify that the browser is reaching the same server on 443.
  2. Inspect apachectl -S for a 443 virtual host containing the exact name.
  3. Add or correct the 443 block, certificate directives, aliases, and intended DocumentRoot.
  4. Reload only after the configuration test succeeds, then inspect the 443 access and error logs.

The domain resolves correctly, but a 404 appears

  1. Use the access log and a unique nonexistent path to prove which host answered.
  2. Read that host’s DocumentRoot from the parsed configuration.
  3. Confirm that the requested file is beneath that directory and that the application’s rewrite rules are present if the URL is routed dynamically.
  4. Check DirectoryIndex for a request to /.

The server’s IP shows a different site than the domain

This is normally expected with name-based hosting. A request made to the bare IP has an IP-based destination but no matching domain name in its Host header, so Apache returns the first virtual host for that address and port. Test with the real hostname, not only the IP, or supply an explicit Host header while diagnosing.

Changes look correct but the old page remains

First check the response headers and logs to make sure the request reaches this Apache instance. Then verify DNS answers from the affected client, including IPv6. A hosts-file override, resolver cache, or an old DNS TTL can keep one machine on a previous address while another machine reaches the new server.

Permissions and access checks after the host is selected

If the correct site is selected but Apache returns 403 or an error-log permission message, inspect the complete path from the filesystem root to the document directory. The Apache service account needs directory traversal permission on each parent and read permission on the served files. Keep application or private data outside the document root rather than making broad permissions changes.

Distribution security controls can also deny access even when traditional Unix permissions look correct. The error log will normally identify a policy denial; correct the policy for the intended directory instead of disabling the protection globally.

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 change-and-test checklist

  1. Resolve the apex, www, and every required subdomain from the affected client.
  2. Compare A and AAAA answers with the server addresses and wait for the relevant TTL after DNS changes.
  3. Test HTTP and HTTPS independently.
  4. Confirm that each required name appears in ServerName or ServerAlias on the correct port.
  5. Confirm an absolute, existing DocumentRoot and the expected DirectoryIndex.
  6. Run sudo apachectl -t; stop if it fails.
  7. Run sudo apachectl -S and verify the parsed map, source file, address, port, and default host.
  8. Reload the appropriate Apache service.
  9. Request a unique nonexistent path and correlate the access and error log entries.
  10. Remove temporary marker files and restore any temporary hosts-file entries when testing is complete.

Bottom line

A domain that appears to point at the wrong Apache directory is usually failing before filesystem mapping. Verify DNS and the IP/port first, match the exact hostname in both HTTP and HTTPS virtual hosts, confirm the parsed configuration with apachectl -S, and only then troubleshoot DocumentRoot, index files, and permissions. The default page identifies an unmatched or wrongly routed request; a 404 or 403 from the intended site points to a separate filesystem or access issue.

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.