简体   繁体   中英

How to remove whole context from the URL in tomcat 8

I want to remove the whole context from the url.

I have already tried the ROOT.war method for removing the war

Let's say my url is --- https://stackoverflow.com/questions/ask

After applying the ROOT.war method i am still getting this-- https://stackoverflow.com/ask

I want my url like this --- https://stackoverflow.com

How can i achieve this in Tomcat 8 version

You are right. You can remove context-root when you rename your *.war file to ROOT.war. What you are talking about is to remove "/ask" from url. It has nothing common with tomcat. In your project you have to set your request to "/" and not to "/ask" . In spring-boot you can set with annotation @GetMapping("/ask") public Greeting sayHello () and it means that when you write in browser https://stackoverflow.com/ask then request go into this method. But when you want to reach the same result but without "/ask" you can write @GetMapping("/ask") . Depends on which framework you are using and there you have to setup this options to redirect request to "/"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM