同一台电脑,家里和公司访问虚拟主机速度竟然不一致。
hosts文件里已手动添加 example.com 127.0.0.1
apache配置文件中添加
<VirtualHost *:80>
    DocumentRoot "D:/example"
    ServerName example.com
</VirtualHost>

解决方案 »

  1.   

    是我在开玩笑还是你在开玩笑?
    hosts文件里已手动添加 example.com 127.0.0.1
    那么 example.com 访问到的就是你作此设置的机器,如果家里和公司访问虚拟主机速度竟然不一致那只能是“携带途中碰坏了”
      

  2.   

    有没有可能是dns或者其它的原因,比如公司一般分配ip为172.*.*.* 我家里分配IP为192.*.*.*
      

  3.   

    127.0.0.1不走DNS. 换句话说,即使没连上网络,你访问example.com也没问题
      

  4.   

    不清楚,我在家里ADSL的笔记本上架了虚拟主机,两个域名指向我的机器,在家里和在公司访问速度基本一致,你这个根本就是lo环回,你自己dig一下看看在公司时候DNS多做了什么事情。
      

  5.   

    你都 hosts文件里已手动添加 example.com 127.0.0.1 了,还解析什么?
    hosts 的作用就是绕过 DNS
      

  6.   

    弱弱的问一下host不是127.0.0.1  www.example.com
      

  7.   

           The domain name queries carried out by gethostbyname() and gethostbyaddr() use a combination of any or all of the name server named(8), a broken
           out line from /etc/hosts, and the Network Information Service (NIS or YP), depending upon the contents of  the  order  line  in  /etc/host.conf.
           (See resolv+(8)).  The default action is to query named(8), followed by /etc/hosts.意思就是先默认是先/etc/hosts,然后DNS,可以配置hosts.conf配置这个先后顺序。