阿帕奇:虚拟主机配置 [英] Apache: Virtual Host configuration

查看:247
本文介绍了阿帕奇:虚拟主机配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试着配置阿帕奇我的虚拟主机。我把这样的事情,

As i tried to configure my virtual host in apache. I put something like this,

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot /xampp/htdocs/gift
   ServerName gift.loc  
</VirtualHost>

在我的hosts文件,我把这样的事情,

And in my hosts file i put something like this,

127.0.0.1       localhost
127.0.0.1       gift.loc

和我在浏览器上运行它,

And i run it on the browser,

http://gift.loc - is fine

但是当我试图用这个,

But when i tried using this,

http://localhost/othersite - can't found

我错过服用点进行配置?任何想法......

Do i missed somehting to configure? ANy ideas...

由于提前,

推荐答案

您需要为您想Apache来处理所有主机虚拟主机条目。如果没有其他VirtualHosts匹配请求在配置文件中的第一个将被用作默认。

You need a VirtualHost entry for every host you want apache to handle. The first one in the config file will be used as the default if no other VirtualHosts match the request.

例如,如果我们有:

<VirtualHost *:80>
   DocumentRoot /xampp/htdocs/gift
   ServerName gift.loc  
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot /example/htdocs/gift
   ServerName example.com  
</VirtualHost>

一个用于foobar.org请求将被gift.loc虚拟主机得到处理。

A request for foobar.org will get handled by the gift.loc virtual host.

这篇关于阿帕奇:虚拟主机配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆