Skip to content

how to change tomcat context path #234

Closed

Description

@lzfxp

If my project name is 'test', when I deploy the web project to Tomcat, it can only be accessed via http://localhost:8080/test. How can I change the 'test' context to the root path '/'?

Activity

  1. jjaychen1e commented on Jan 23, 2025

    @jjaychen1e

    Same question here

  2. heliusjing commented on Apr 11, 2025

    @heliusjing

    I would like to know too

  3. robstryker commented on Apr 17, 2025

    @robstryker
    Collaborator

    You have a couple of options:

    Remove the out-of-the-box ROOT/ directory from tomcat and rename your war file to ROOT.war before deploying it.
    
    Deploy your war as (from your example) war_name.war and configure the [context root](https://tomcat.apache.org/tomcat-8.0-doc/config/context.html) in conf/server.xml to use your war file :
    
    <Context path="" docBase="war_name" debug="0" reloadable="true"></Context>
    

    The first one is easier, but a little more kludgy. The second one is probably the more elegant way to do it.

    https://stackoverflow.com/questions/5328518/deploying-my-application-at-the-root-in-tomcat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions