You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache显示默认索引页而非虚拟主机页面,Win10手动部署求助

Troubleshooting Apache Virtual Host Not Working on Windows 10

Hey there, let's work through this virtual host issue together—this is a super common pitfall when moving from XAMPP to a manual Apache setup, so we'll get it sorted quickly!

Here are the key steps to fix your test.com virtual host still showing the default Apache page:

1. Ensure Apache is loading your virtual hosts configuration

First, Apache doesn't load the virtual hosts file by default. You need to enable it in your main httpd.conf:

  • Open C:/Server/Apache24/conf/httpd.conf in a text editor
  • Look for the line that says #Include conf/extra/httpd-vhosts.conf
  • Remove the leading # to uncomment it (this tells Apache to load the virtual hosts config file)
  • Save httpd.conf

2. Map test.com to your local machine via the hosts file

Your Windows PC doesn't know where test.com points unless you tell it:

  • Open Notepad as Administrator (right-click > Run as administrator)
  • Go to File > Open and navigate to C:\Windows\System32\drivers\etc\hosts (change the file type filter to "All Files" to see it)
  • Add these lines at the bottom:
    127.0.0.1 test.com
    ::1 test.com
    
  • Save the file, then open Command Prompt and run ipconfig /flushdns to clear DNS cache

3. Add directory permissions to your virtual host

Your current virtual host config is missing a critical piece: explicit permissions for the test directory. Without this, Apache might block access and fall back to the default page. Update your virtual host config (in conf/extra/httpd-vhosts.conf) to include:

<VirtualHost *:80>
    DocumentRoot "C:/Server/Apache24/htdocs/test"
    ServerName test.com

    # Add this directory block to grant access
    <Directory "C:/Server/Apache24/htdocs/test">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    # Optional: Ensure index.php is prioritized
    DirectoryIndex index.php index.html
</VirtualHost>

4. Restart Apache

Any config changes require a restart to take effect:

  • Open the Apache Service Monitor (or use Command Prompt)
  • Run httpd -k restart from C:/Server/Apache24/bin (or just use the service monitor's restart button)

5. Test with a fresh browser session

Browsers often cache old page data. Try accessing test.com in an incognito/private window to rule out cached content.

After following these steps, test.com should load the content from your C:/Server/Apache24/htdocs/test directory instead of the default Apache page!

内容的提问来源于stack exchange,提问作者John Deck

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:17:08