开发者

How to redirect website to different folder and not ROOT in tomcat ?

i am using tomcat. i have a folder with my website in it called exampleSite

when i go to my website www.example.com i would like the开发者_运维问答 index.html inside exampleSite to load up and not the IndexFile within ROOT.

How would i go about achieving this?


There are two ways of deploying a web application on the filesystem:

  1. Copy your WAR file or your web application's directory (including all of its content) to the $CATALINA_BASE/webapps directory.

  2. Create an XML fragment file with just the Context element for your web application, and place this XML file in $CATALINA_BASE/webapps. The web application itself can then be stored anywhere on your filesystem.

Another way to deploy a web app is by writing a Context XML fragment file and deploying it into the CATALINA_BASE/webapps directory. A context fragment is not a complete XML document, but just one Context element and any subelements that are appropriate for your web application. These files are like Context elements cut out of the server.xml file, hence the name "context fragment."

For example, if we wanted to deploy the WAR file MyWebApp.war along with a realm for accessing parts of that web application, we could use this fragment:

<!--  
  Context fragment for deploying MyWebApp.war  
 -->
<Context path="/demo" docBase="webapps/MyWebApp.war" 
         debug="0" privileged="true">
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"                
         resourceName="UserDatabase"/> 
</Context>

Put that in a file called "MyWebApp.xml," and copy it into your CATALINA_BASE/webapps directory.

These context fragments provide a convenient method of deploying web applications; you do not need to edit the server.xml file and, unless you have turned off the default liveDeploy feature, you don't have to restart Tomcat to install a new web application.

Reference

  • Top Ten Tomcat Configuration Tips
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜