Tomcat can access projects with only IP and port without project name

Source: Internet
Author: User

Today, we find that the Tomcat project on production only uses the ip+ port to access the project, it is very strange, baffled its solution, a variety of attempts, and finally find out why


Cases:

Http://192.168.50.248:8081/login.htm can go directly to the project login page

Http://192.168.50.248:8081/project/login.htm can also access the project login page


So, my local Tomcat tried, and found that if the project name is not added, access is 404,

Later I added the project name, login page can access, but login success, jump to Index.htm, the project name is missing and the response is 404


Later found that the original Tomcat is the default startup project, if you configure the Tomcat default startup Project , you can access the project without the project name


Here's how:

1. Open the Tomcat installation root directory, open the Conf directory under Service.xml, Locate the <Host> node, and add it under this node:

<context docbase= " /home/tomcat/webapps/project "path=" "debug=" 0 "reloadable=" true "/>

Description: Purple site for your project path, as I was placed in the WebApps directory, so point to WebApps


2. Open the WebApps directory under the Tomcat directory to find the root project and change it to another name


3. Restart Tomcat


Once the reboot is successful, the project can be accessed directly from the IP address + port in the browser.

Example: http://localhost:8081/login.htm



Finally: I still have a question , according to reason my first path has the project name, then my next relative path request should also have the project name

As if the http://192.168.50.248:8081/project/login.htm request is accessible to the login page, but why did I request success, return "/index",

Should return to http://192.168.50.248:8081/project/index.htm as normal.

But returned when the project name was also lost , the address into a http://192.168.50.248:8081/index.htm , this is my very doubtful place, tried a lot of places, do not know where to configure the


Tomcat can access projects with only IP and port without project name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.