Java – Redirects in Glassfish (adding trailing slash)

configurationglassfishjavaredirect

Is it possible to add a trailing slash to the default context of an application?

Example:

http://www.uri.com/foo -> http://www.uri.com/foo/

I added the following redirect to the server properties:

redirect_1: from=/foo url-prefix=/foo/

and this ends up in a loop…
Several other configurations also didn't work :-/

I'm using glassfish v2.1-b60e.

Best Answer

I would recommend to use a pure http server in front of glassfish or any application server like apache (http://httpd.apache.org/docs/2.2/mod/mod_proxy.html) or nginx (http://nginx.net/) that handles your domains/urls.

You could try to use this tutorial as a starting point: http://communitymapbuilder.org/display/JETTY/Configuring+mod_proxy

I know it is targeted to jetty but it should provide you some information on the topic.

Related Topic