正常的请求一个项目的路径是:http://ip地址:端口号/项目名。
设置tomcat下conf文件下的server.xml配置文件实现只请求ip地址来访问项目
- 1 找到server.xml配置文件并打开,在大概文件末尾的位置找到如下形式的代码:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <!--填写处-->
- 在上面填写处的地方填写下面的代码:
<Context path="" docBase="/home/webuser/tomcat5.5.28/webapps/xiangmu" debug="0" reloadable="true"/>
- 最后将8080端口指向80端口请求
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
重启tomcat之后在web地址栏输入:ip地址 即可