Tux

...making Linux just a little more fun!

Apache -- Rewrite on hiding Webapp context from URL

Britto I [britto_can at yahoo.com]


Sun, 6 Sep 2009 04:06:55 -0700 (PDT)

Folks:

I would like to have some configuration advice from you guys for apache.

I have Apache 2.2.8 running in RHEL box.

I have multiple webapps running in tomcat and connected through apache via ajp proxy.

Now we have the Rewrite rules..like

RewriteRule ^/Context1$ /Context1/ [R]
RewriteRule ^/Context2$ /Context2/ [R]
RewriteRule ^/$ /DefaultContext/ [R]

Here Context1,Context2, DefaultContext all are different webapps hosted by tomcat.

When somebody calls for www.mysite.com it goes to www.mysite.com/DefaultContext/ now.

How can I disable or hide the Defaultcontext being displayed in the URL.

So that if there is some hit at www.mysite.com/DefaultContext/DoAction it should display the user www.mysite.com/DoAction

Any advice guys ..

Thanks & regards, Britto


Top    Back


Anderson Silva [afsilva at gmail.com]


Sun, 6 Sep 2009 08:24:55 -0400

I think to do that you will need to use apache's mod_proxy, or change your DocumentRoot on the apache config.

AS


Top    Back


Britto I [britto_can at yahoo.com]


Sun, 6 Sep 2009 06:28:22 -0700 (PDT)

Thanks Anderson.

I am already using mod_proxy.

I have some static images which is currently being severed under Docroot.

and additions to that is it possible to do like..

RewriteRule ^/Context$ /Context/ 
ProxyPass /Context ajp://localhost:8009/Context/
DocumentRoot /Context

I was assuming that document root can point only to the directories.

-- 
Britto


Top    Back


Anderson Silva [afsilva at gmail.com]


Sun, 6 Sep 2009 13:20:48 -0400

try:

ProxyPass / ajp://localhost:8009/Context/


Top    Back


Britto I [britto_can at yahoo.com]


Sun, 6 Sep 2009 11:01:47 -0700 (PDT)

Sure Anderson.

I will try and let you know.

-- 
Britto


Top    Back


Britto I [britto_can at yahoo.com]


Wed, 9 Sep 2009 06:56:02 -0700 (PDT)

Not sure why...

But mounting DefaultContext to / produces slowness in the server ...

Now reverted back the changes..

Any other proposed method.. to solve this problem ..

-- 
Britto


Top    Back


Anderson Silva [afsilva at gmail.com]


Wed, 9 Sep 2009 10:11:06 -0400

On Wed, Sep 9, 2009 at 9:56 AM, Britto I<britto_can@yahoo.com> wrote:

> Not sure why..
>
> But mounting DefaultContext to / produces slowness in the server ...
>
> Now reverted back the changes..
>
> Any other proposed method.. to solve this problem ..

here's another idea, with mod_rewrite:

RewriteRule ^/$      http://something/DefaultContext/ [P,L]

the option P makes it force a proxy

You may have to adjust your regexp above, this is just a simple example.

-- 
http://www.the-silvas.com


Top    Back