Search code examples
http-redirectmod-rewriteweblogicoracle-http-server

weblogic & OHS: How forward one url to a different server


I have an environment with Oracle WebLogic and OHS running.

In the mod_wl_ohs.conf I have following (beside config for other applications)

  <Location /application1>
    SetHandler weblogic-handler
    WLLogFile /opt/logs/ application1.log
    Debug OFF
    WebLogicHost 127.0.0.1
    WebLogicPort 23666
  </Location>

This works fine the and the server listening to 23666 with the actual application1 application is handling the requests like “http://example.com/application1/*” .

Now I would like to redirect all requests for specific URL pattern to a different domain (not necessary on the same server), but continuing handling all requests others.
Redirect: http://example.com/application1/MagicKeyword/*
continue on: http://example.com/application1/NotTheKeyword* or http://example.com/application1/AlsoNotKeyword/*

What is the right approach for that?
I played around with some mod_rewrite rules, it seems they don’t take affect or break everything (in httpd.conf). I was also reading that we should not use mod_rewrite rules inside of location tag (can't find the reference now).
What else can I do?

Edit: So finally I found my error (somehow wrong syntax which not prevented the server from starting (like usual).

So I could: in httpd.conf

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule "(.*)/application1/MagicKeyword/(.*)$" "https://www.example.org" [NC,L,R=301]
</IfModule>

or in the Location tag add:

RewriteEngine On
RewriteRule "(.*)/MagicKeyword/(.*)$" "https://www.example.org" [NC,L,R=301]

Why should I prefer one over the other? Is there anything to concern about?


Solution

  • Two other options you can consider. You can use the order of location tags:

    <Location /application1/MagicKeyword>
        WebLogicHost otherhost
    </Location> 
    <Location /application1>
        WebLogicHost 127.0.0.1
    </Location> 
    

    You can tell WebLogic to exclude a path (see https://docs.oracle.com/middleware/1212/webtier/PLGWL/plugin_params.htm#PLGWL473):

    <Location /application1>
        WebLogicHost 127.0.0.1
        WLExcludePathOrMimeType /application1/MagicKeyword
    </Location> 
    <Location /application1>
        WebLogicHost otherhost
    </Location>