0

我的 Windows 计算机上安装了 WAMP。

我想在以下地址上设置一些虚拟服务器:

127.0.0.1 to localhost/website1/
127.0.0.2 to localhost/website2/

这是我的主机文件的内容:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
127.0.0.1 localhost/website1
127.0.0.2 localhost/website2

但它们似乎都不起作用。这两个地址都只是引导我到本地主机根。

如果我访问http://localhost/website1http://localhost/website2它们都可以工作。

难道我做错了什么?

我对 IP 地址完全灵活。

4

1 回答 1

1

您需要将虚拟主机添加到httpd-vhosts.conf(Apache 服务器的,它位于类似 wamp\bin\apache\Apache2.2.11\conf\extra 的文件夹内)添加虚拟主机的示例在该文件中。并且您可能还需要从httpd.conf文件中的以下行中取消注释(删除 # 符号)

Include conf/extra/httpd-vhosts.conf
于 2011-11-30T09:01:50.380 回答