On Fri, Jun 13, 2014 at 8:37 AM, Konstantin Kolinko <knst.koli...@gmail.com> wrote: > 2014-06-12 21:56 GMT+04:00 Colin Ingarfield <colin...@gmail.com>: >> Hello, >> >> Is it possible in Tomcat 6/7 to create an alias for a context? We >> have a context that includes an underscore and that is unfortunately >> causing problems w/ a load balancer and cookie paths. Our URLs >> resemble this: >> https://example.com/the_context/login.jsp >> >> Where we have deployed a war file named "the_context.war". >> >> I'd like to somehow alias the context name so both of these urls would >> effectively be the same: >> https://example.com/the_context/login.jsp >> https://example.com/thecontext/login.jsp >> >> Ideally this would be done w/o deploying the application twice. Is >> this possible in Tomcat 6 and/or 7 ? >> > > > While it may be possible to create an "alias" my hacking into Tomcat's > mapper component (that maps requests to Contexts), you will have > problem if your web application calls ServletContext.getContextPath() > as that information does not depend on the incoming request. > > There are two typical solutions: > a) Name one URL as "the canonical" one and redirect your users from > the old URL to the new one. That is to respond with HTTP status code > 301 and a redirection. > b) Rewrite URLs in the incoming request and in response (if needed). > > a) can be done by a simple Filter or by using a standard "rewrite" one > b) needs some mode advanced rewrite implementation > > You may use UrlRewriteFilter [1] (in any version of Tomcat), > RewriteValve (in Tomcat 8), > mod_rewrite in Apache HTTPD server (if your Tomcat runs behind that server). > > [1] http://wiki.apache.org/tomcat/AddOns#UrlRewrite > > Best regards, > Konstantin Kolinko > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org >
OK, that makes sense and I can see how this could be done w/ just a Filter. And thank you for the link to UrlRewrite... I was not aware of it and it looks very powerful/flexible. Thanks! --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org