0

I have a Java application deployed on Oracle Weblogic server which can be accessed via http://www.example.com/myapp

This works fine but now I want to get rid of "myapp" in the URL so the application can be accessed only via http://www.example.com

Is this possible? If yes, how?

Timo Ernst
  • 15,243
  • 23
  • 104
  • 165
  • 2
    You should be able to do this by changing the context root to `/` https://docs.oracle.com/cd/E23943_01/web.1111/e13712/weblogic_xml.htm#WBAPP623 – yate Dec 12 '14 at 14:47
  • @yate we're using JBoss but AFAIK context root `/` or even empty is not allowed in application.xml. – Thomas Dec 12 '14 at 14:52
  • The only info I could find on JBoss was [this link](https://docs.jboss.org/jbossas/guides/webguide/r2/en/html/ch06.html) which says it is possible to use `/` as your context root. I don't think an empty context root is allowed though – yate Dec 12 '14 at 15:36
  • @yate yes, you can achieve the effect of context root `/` but AFAIK not by setting it in application.xml but rather in JBoss configuration or by naming your application ROOT.war. If you map multiple domains to multiple applications in the same JBoss instance you'd either have to use distinct context roots or add some url rewriting, so I'd just go that way right from the start. – Thomas Dec 12 '14 at 15:55
  • 1
    Please see this similar question - lots of good tips: http://stackoverflow.com/questions/15843594/how-can-i-use-weblogic-12-c-without-the-application-context-in-the-url – Display Name is missing Dec 12 '14 at 16:52

3 Answers3

0

I don't know about Weblogic but in JBoss and Tomcat you'd name your application ROOT.war.

IMHO this is not desirable so I'd employ some URL rewriting, e.g. by using an intermediate apache webserver, which then forwards /myapp(/.*) to $1.

Of course you'd have to remove the context root from any internally generated links, but how that is done would depend on your application and environment.

Thomas
  • 87,414
  • 12
  • 119
  • 157
0

I deploy a Reverse Proxy, you can use Oracle HTTP Server or Apache for this, I use mod_wl_ohs in the OHS and it's pretty simple:

<VirtualHost *:80>
ServerName  myexample.com
 <IfModule weblogic_module>
  DynamicServerList On
  WebLogicHost <IP of the weblogic>
  WebLogicPort <PORT>
  <Location />
   RedirectMatch ^/$ /store
   SetHandler weblogic-handler
   WebLogicHost <IP of the weblogic>
   WebLogicPort <PORT>
  </Location>
 </IfModule>
</VirtualHost>

Plus, it'll give you another security layer if you setup and URL-Firewall using REWRITE mod.

VictorV
  • 36
  • 3
0

<context-root> in application.xml needs to be set to / like this:

<web>
  <web-uri>web.war</web-uri>
  <context-root>/</context-root>
</web>

Further reading:

Timo Ernst
  • 15,243
  • 23
  • 104
  • 165