Tomcat can access the project by using only the ip address and port, without the project name. tomcatip
Today, I found that the production tomcat project can only access the project using ip + port. I think it is strange that I cannot solve it. I tried to find out the reason.
Example:
Http: // 192.168.50.248: 8081/login.htm can directly enter the project login page
Http: // 192.168.50.248: 8081/project/login.htm can also enter the project login page
So I tried tomcat locally and found that if the project name is not added, the access would be 404,
After that, I added the project name and added the webpage to the project. However, the project name was lost and the response was 404 again.
Later, we found that it was originally caused by the default startup project of tomcat. If the default startup project of tomcat is configured, you can access the project without the project name.
The procedure is as follows:
1. Open the tomcat installation root directory, open service. xml under the conf directory, find the <Host> node, and add it under the node:
<Context docBase = "/home/tomcat/webapps/project" path = "" debug = "0" reloadable = "true"/>
Note: The Purple part is your project path. Because I put it under the webapps directory, it points to webapps.
2. Open the webapps directory under the tomcat directory, find the ROOT project, and change it to another name.
3. Restart Tomcat
After the restart is successful, you can directly access the project using the IP address and port in the browser.
Example: http: // localhost: 8081/login.htm
Finally, I still have a question. As a result, my initial path has a project name, so my next relative path request will also contain the project name.
It seems that the http: // 192.168.50.248: 8081/project/login.htm request can access the logon page, but why is the request successful? When return "/index,
Normally, http: // 192.168.50.248: 8081/project/index.htm should be returned.
However, the project name is also lost and the address is changed to http: // 192.168.50.248: 8081/index.htm. This is what I have a lot of questions about, I don't know where to configure it.