ここで何が起こっているのかわかりませんが、MAC OS X で MAMP 1.9 を実行しています。私の httpd.conf ファイルでは、DocumentRoot がデフォルトの htdocs パスに設定されています。htdocs フォルダー内に、仮想ホストとして設定するために、いくつかの「サブサイト」を作成しました。指定されたパスにアクセスできますが、最初に設定したパスがデフォルトになっているようです。 .
基本的に、最初に構成した VirtualHost は site1.localhost.com 用でした。それ以来、site2.localhost.com と site3.localhost.com を構成しました。ただし、最後の 2 つのアドレスのいずれかにアクセスすると、常に site1.localhost.com にリダイレクトされるようです。さらに、localhost.com:8888 に移動すると、site1.localhost.com が表示されます。どこで間違いを犯したのかわかりませんが、ここの誰かが問題を解決するのを手伝ってくれることを願っています...ああ、/ etc /に変更を加えた後、Apacheなどを再起動しましたhosts または httpd.conf ファイル。
私のhttpd.confファイル(関連する部分、とにかく...):
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# MAMP DOCUMENT_ROOT !! Don't remove this line !!
DocumentRoot "/Applications/MAMP/htdocs"
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/Applications/MAMP/htdocs">
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/site1/"
ServerName site1.localhost.com
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/sub/site2/"
ServerName site2.localhost.com
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/sub/site3/"
ServerName site3.localhost.com
</VirtualHost>
/etc/hosts ファイルで:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 site1.localhost.com
127.0.0.1 site2.localhost.com
127.0.0.1 site3.localhost.com
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost