我正在尝试更改从WAMP服务器访问网站的方式。我可以像xxx.xxx.xxx.xxx / name一样访问它,是的,它完全正常。我搜索了如何将“xxx.xxx.xxx.xxx/name”更改为域名,如www.name.com,我得到了一些结果,但没有一个工作。这些是我做的事情:
首先我去了我的主机文件
C:\ Windows \ System32下\驱动程序\等
,添加了一行“127.0.0.1 mytestdomain.com”,它的外观如下: host file
接下来,我将位于以下位置的httpd.conf中的“#Include conf / extra / httpd-vhosts.conf”更改为“Include conf / extra / httpd-vhosts.conf”:
“d:\ wamp64 \ BIN \阿帕奇\ apache2.4.27 \ CONF”
最后,我添加了
<VirtualHost mytestdomain.com>
DocumentRoot "D:/wamp64/www/myTestDomain/"
ServerName mytestdomain.com
ServerAlias mytestdomain.com
<Directory "D:/wamp64/www/myTestDomain/">
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
位于“httpd-vhosts.conf”的位于:
“d:\ wamp64 \ BIN \阿帕奇\ apache2.4.27 \ CONF \额外的”
哦,是的,这是在myTestDomain文件夹中:myTestDomain
完成所有这些后,我重新启动WAMP并转到我的域主服务器,但它似乎没有工作,同时“xxx.xxx.xxx.xxx/myTestDomain”似乎确实有效。
答案 0 :(得分:0)
您的HOSTS文件应如下所示
127.0.0.1 localhost
127.0.0.1 mytestdomain.com
::1 localhost
::1 mytestdomain.com
您的虚拟主机定义如下
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp64/www
<Directory "D:/wamp64/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/wamp64/www/myTestDomain/"
ServerName mytestdomain.com
ServerAlias mytestdomain.com
<Directory "D:/wamp64/www/myTestDomain/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
或者打开wampserver主页并使用Add a Virtual Host
菜单下的Tools
链接,这一切都将正确完成。
注意:使用
.com
是一个坏主意,除非您确实打算从PC托管您的实际网站,而是使用.dev
。相应地更改HOSTS文件。更大注意:从PC托管实时网站是一个非常糟糕的主意。如果您使用的是桌面操作系统,则它未配置为处理超过30个外部连接,因此如果您的网站变得非常流行,用户将获得糟糕的体验,其中大多数都会排队等待下载页面部分的连接。