Well, you should check out the url rewrite documention for details. In your webapp's web.xml, you put something like this in to tell it you want it to examine all URLs that come into the web app:

<filter>
       <filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
   <init-param>
       <param-name>logLevel</param-name>
       <param-value>log4j</param-value>
   </init-param>
   <init-param>
       <param-name>confReloadCheckInterval</param-name>
       <param-value>60</param-value>
   </init-param>
</filter>
<filter-mapping>
       <filter-name>UrlRewriteFilter</filter-name>
       <url-pattern>/*</url-pattern>
</filter-mapping>

Note that I have set the logLevel to 'log4j' because that's what we use, but you can set it values like DEBUG, etc. or 'commons' if you use the commons logging.

In the same WEB-INF location where web.xml is defined, you configure the urlrewrite.xml file, with something like:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.5//EN"
   "http://tuckey.org/res/dtds/urlrewrite2.5.dtd";>

<!--

   Configuration file for UrlRewriteFilter
   http://tuckey.org/urlrewrite/

-->
<urlrewrite>

   <rule>
       <note>
Anything coming to / or any number of subsequent slashes should just go to the public site.
       </note>
       <from>^/siteB(.*)$</from>
       <to type="redirect">http://localhost:8080/sideB$1</to>
   </rule>

Note that the actual rule depends a bit on where you define this. The above <from> entry assumes that /siteB is specified and being processed by the root webapp (context "/"). If you are defining url rewrite in a webapp with a context of '/siteB' then you would assume the /siteB/ context path and use a from of just: /(.*)$

No doubt there are better ways to configure it, but I'm not a URL rewrite expert. But what you are doing sounds very straightforward and it should work for you.

David


Lothar Krenzien wrote:

Hi David ,

it looks interesting. But what I don't understand, when I define the filter in the project web.xml how does tomcat knows where to look when the entered url in the browser contains a project name which doesn't exits ? I think, when a user enters localhost:80/siteB I need to have a project in my webapp dir called projectB. What I want is, to redirect some specific urls to another server .
My previous post contains a mistake :

localhost:80/siteB should be forwared to localhost:8080/siteB because I don't 
have an app siteB, but the clients would like to use only one hostname.

Thanks, Lothar

-----Ursprüngliche Nachricht-----
Von: "Tomcat Users List" <users@tomcat.apache.org>
Gesendet: 16.03.06 19:36:46
An: Tomcat Users List <users@tomcat.apache.org>
Betreff: Re: redirect with tomcat


We've used UrlRewriteFilter with good success so far: http://tuckey.org/urlrewrite/

David

Lothar Krenzien wrote:

Hi there,

I'm using tomcat 5.5 and want to redirect some requests to another URL. For example the URL 
localhost:80/siteA  should be forwarded to localhost:8080/siteB. Of course on Port 8080 
listen another web-server. Does anybody know a good explanation how to do that ? I've tried 
with filters in <catalina_home>/conf/web.xml and put the classes in the  
<catalina_home>/server/classes and also by defining forwarding-rules in a rules.xml 
file. But all with no success.


Thanks for your answer.

Lothar
__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail-Postfach!        
        
Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to