[英]How to remove application context from URL in apache tomcat
I have a war test.war. 我有一个战争测试。 I deployed it in webapps folder.
我将其部署在webapps文件夹中。
Now I can access the web application by URL www.domain.com/test/login 现在,我可以通过URL www.domain.com/test/login访问Web应用程序
In order to remove the war name, I renamed the war to ROOT.war 为了删除战争名称,我将战争重命名为ROOT.war
So Now I am able to access the web application by URL www.domain.com/login 因此,现在我可以通过URL www.domain.com/login访问Web应用程序
Can someone please guide me How to access the web application by URL www.domain.com 有人可以指导我如何通过URL www.domain.com访问Web应用程序
PS I cannot modify the contents of my WAR file. PS我无法修改WAR文件的内容。
Put a HTTP server in front of your application server. 将HTTP服务器放在应用程序服务器的前面。 That will allow you to create and redirect virtual hosts into specific URLs inside your application server.
这样,您就可以在应用程序服务器内部创建虚拟主机并将其重定向到特定的URL。 It's called a reverse proxy.
这称为反向代理。
Eg 例如
www.domain.com -> localhost:8080/mylogin
subdomain.domain.com -> localhost:8080/otherapp/frontpage
If you are using Tomcat 7+, you can use an empty URI pattern in your web.xml to map an empty request to the context root. 如果使用的是Tomcat 7+,则可以在web.xml中使用空的URI模式将空的请求映射到上下文根。
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>com.example.LoginServlet</servlet-class>
...
</servlet>
...
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
Tomcat 8 has a URL rewrite mechanism.similar to Apache's mod_rewrite. Tomcat 8具有URL重写机制,类似于Apache的mod_rewrite。
See http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html 参见http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.