@@ -38,9 +38,7 @@ public static void serveIndex(IMxRuntimeResponse response, String indexpage) {
3838 location = INDEXPAGE ;
3939 }
4040
41- if (!location .startsWith ("/" )) {
42- location = "/" + location ;
43- }
41+ location = getRootUrl () + ensureStartingSlash (location );
4442
4543 if (LOG .isTraceEnabled ()) {
4644 LOG .trace ("Redirecting to index location: " + location );
@@ -80,6 +78,8 @@ public static void serveSSOHandler(IMxRuntimeRequest request, IMxRuntimeResponse
8078 java .nio .charset .StandardCharsets .UTF_8 .toString ());
8179 }
8280
81+ redirectLocation = getRootUrl () + ensureStartingSlash (redirectLocation );
82+
8383 response .setStatus (IMxRuntimeResponse .SEE_OTHER );
8484 response .addHeader ("location" , redirectLocation );
8585 } else {
@@ -139,12 +139,11 @@ public static void serveLogin(IMxRuntimeRequest request, IMxRuntimeResponse resp
139139 }
140140
141141 if (!loginLocation .startsWith ("http" )) {
142- loginLocation = ensureStartingSlash (loginLocation );
142+ loginLocation = getRootUrl () + ensureStartingSlash (loginLocation );
143143 }
144144
145145 response .setStatus (IMxRuntimeResponse .SEE_OTHER );
146146 response .addHeader ("location" , loginLocation );
147-
148147 }
149148
150149 private static String ensureStartingSlash (String s ) {
@@ -169,4 +168,13 @@ private static String ensureNoStartingSlash(String s) {
169168 return s ;
170169 }
171170
171+ private static String getRootUrl ()
172+ {
173+ String url = Core .getConfiguration ().getApplicationRootUrl ();
174+ String path = ensureStartingSlash (URI .create (url ).getPath ());
175+ if (path .endsWith ("/" ))
176+ return path .substring (0 , path .length () - 1 );
177+ return path ;
178+ }
179+
172180}
0 commit comments