虚拟主机和虚拟目录配置

要想在本机上出现这样:输入www.baidu.com,但是进入的却是自己的目录

1.在windows/system32/etc/host文件中添加

  127.0.0.1  www.baidu.com

2.在tomcat/conf/server.xml文件中添加

   <Host name="www.baidu.com"  appBase="d:\ship"><!--此处即为添加虚拟主机,这个的在第一部完成后才能添加,否则启动tomcat报错-->
     <Context path="jsp" docBase="d:\ship\html" /><!--此处即为添加虚拟目录-->
      </Host>

3.启动tomcat,浏览器输入:http://www.baidu.com/jsp/即进入到默认的页面

当然需要在目录下web.xml中添加

 <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

这时才能够实现进入默认index.html,

且server.xml的端口号为80

 

posted on 2015-04-08 12:57  菜鸟的足迹  阅读(378)  评论(0)    收藏  举报