|
27 | 27 | import java.io.IOException; |
28 | 28 | import java.util.ArrayList; |
29 | 29 | import java.util.EnumSet; |
| 30 | +import java.util.HashSet; |
30 | 31 | import java.util.List; |
31 | 32 |
|
32 | 33 | import static de.rwth.idsg.steve.SteveConfiguration.CONFIG; |
@@ -112,24 +113,32 @@ private Handler getRedirectHandler() { |
112 | 113 | rewrite.setRewriteRequestURI(true); |
113 | 114 | rewrite.setRewritePathInfo(true); |
114 | 115 |
|
115 | | - String root = CONFIG.getContextPath(); |
116 | | - |
117 | | - String[] redirectArray = { |
118 | | - "", |
119 | | -// root + "", |
120 | | -// root + "/", |
121 | | - }; |
122 | | - |
123 | | - for (String redirect : redirectArray) { |
| 116 | + for (String redirect : getRedirectSet()) { |
124 | 117 | RedirectPatternRule rule = new RedirectPatternRule(); |
125 | 118 | rule.setTerminating(true); |
126 | 119 | rule.setPattern(redirect); |
127 | | - rule.setLocation(root + "/manager/home"); |
| 120 | + rule.setLocation(CONFIG.getContextPath() + "/manager/home"); |
128 | 121 | rewrite.addRule(rule); |
129 | 122 | } |
130 | 123 | return rewrite; |
131 | 124 | } |
132 | 125 |
|
| 126 | + private HashSet<String> getRedirectSet() { |
| 127 | + String path = CONFIG.getContextPath(); |
| 128 | + |
| 129 | + HashSet<String> redirectSet = new HashSet<>(3); |
| 130 | + redirectSet.add(""); |
| 131 | + redirectSet.add(path + ""); |
| 132 | + |
| 133 | + // Otherwise (if path = ""), we would already be at root of the server ("/") |
| 134 | + // and using the redirection below would cause an infinite loop. |
| 135 | + if (!"".equals(path)) { |
| 136 | + redirectSet.add(path + "/"); |
| 137 | + } |
| 138 | + |
| 139 | + return redirectSet; |
| 140 | + } |
| 141 | + |
133 | 142 | // ------------------------------------------------------------------------- |
134 | 143 | // JSP stuff |
135 | 144 | // |
|
0 commit comments