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

WAMP Server虚拟主机地址跳转至谷歌搜索页面问题求助

Troubleshooting WAMP Virtual Host Redirecting to Google

Let's walk through fixing this redirect issue—this is a super common problem with WAMP virtual hosts, so we'll get your www.tour.test working correctly in no time.

Step 1: Verify Your Windows Hosts File

The most likely culprit is that your system isn't resolving www.tour.test to your local WAMP server. Here's how to fix it:

  • Open Notepad as Administrator (right-click → Run as administrator)
  • Open the file at C:\Windows\System32\drivers\etc\hosts
  • Add these two lines at the bottom of the file:
    127.0.0.1 www.tour.test
    ::1 www.tour.test
    
  • Save the file and close Notepad. This tells your computer to point that domain to your local machine instead of querying external DNS (which might redirect unregistered domains to Google).

Step 2: Validate Apache Configuration Syntax

A tiny syntax error in your virtual host config can break everything. Let's check:

  • Click the WAMP icon in your system tray → Apache → Service → Test port 80 (this checks if Apache can start correctly)
  • Alternatively, open Command Prompt, navigate to your Apache bin folder (e.g., C:\wamp64\bin\apache\apacheX.X.X\bin), and run:
    httpd -t
    
  • If you see Syntax OK, great. If not, fix the reported errors (common issues include missing closing tags or typos in paths).

Step 3: Ensure Virtual Hosts Are Enabled in Apache

WAMP doesn't always enable virtual hosts by default. Let's confirm:

  • Click WAMP icon → Apache → httpd.conf
  • Search for the line:
    #Include conf/extra/httpd-vhosts.conf
    
  • Remove the # at the start to uncomment it, then save the file.
  • Restart Apache (WAMP icon → Apache → Restart Service) to apply the change.

Step 4: Update Virtual Host Permissions (Apache 2.4+)

Your project virtual host uses old Apache 2.2-style permissions (Order Allow,Deny / Allow from all). If you're running Apache 2.4 (which most modern WAMP installs use), replace those lines with the 2.4 syntax:

<VirtualHost *:80>
 ServerName www.tour.test
 DocumentRoot "C:/wamp64/tour/public"
 SetEnv APPLICATION_ENV "development"
 <Directory "C:/wamp64/tour/public">
 DirectoryIndex index.php
 AllowOverride all
 Require all granted
 </Directory>
</VirtualHost>
  • Also, note that <directory> should be capitalized to <Directory> (while Windows is case-insensitive, it's good practice to match Apache's standard syntax).
  • Restart Apache after making this change.

Step 5: Clear Browser & DNS Cache

Old cached data can cause unexpected redirects:

  • DNS Cache: Open Command Prompt and run:
    ipconfig /flushdns
    
  • Browser Cache: Clear your browser's cache/cookies, or test in an incognito/private window (this bypasses cached data).

Step 6: Check for Problematic .htaccess Rules

If you have an .htaccess file in C:/wamp64/tour/public, it might contain incorrect rewrite rules that trigger the redirect:

  • Open the .htaccess file and look for any lines starting with RewriteRule that point to external sites (like Google).
  • Temporarily rename the file to .htaccess.bak and test accessing www.tour.test again. If the redirect stops, you'll need to fix the rules in that file.

内容的提问来源于stack exchange,提问作者Mohammad Sadeghyan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 03:23:04