我怎样才能让Apache虚拟主机工作?

好的,我一直在争取这一个星期,

我有我的家庭服务器上运行的Xampp,我正在尝试让子域名工作,我编辑我的Windows主机文件,以便所有这些加载我的网站,

http:// localhost / http://mydomain.com/

http://images.mydomain.com/ http://images.localhost/

然后,我修改了我的Apache conf文件来添加我的虚拟主机,使images.mydomain.com和images.localhost加载我的localhost / images文件夹,但由于某些原因,他们加载的内容http:// localhost /就像我我要去正规网站,而不是一个子域名,为什么?

NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /htdocs/images/ ServerName images.localhost </VirtualHost> <VirtualHost *:80> DocumentRoot /htdocs/images/ ServerName images.mydomain.com/ </VirtualHost> <VirtualHost *:80> DocumentRoot /htdocs/ ServerName mydomain.com/ </VirtualHost> 

尝试删除ServerName行上的结尾斜杠。

或者给文件夹的完整path:

DocumentRoot c:/ htdocs / mydomain ServerName mydomain.com/

如果你ping到images.mydomain.com会发生什么? 你从你的服务器获得回应吗?

我想你忘了添加“到DocumentRoot。你应该尝试这样的DocumentRoot”/ htdocs / images /“

你是否使用条目images.localhost填充你的/ etc / hosts?