Redirect /Documentation(/)? to /Documentation/index.html
Bug: Issue 9974
Change-Id: Idf415661d82ab171101b2da036c29f2cd336da87
diff --git a/java/com/google/gerrit/httpd/UrlModule.java b/java/com/google/gerrit/httpd/UrlModule.java
index 6620c44..183b2bd 100644
--- a/java/com/google/gerrit/httpd/UrlModule.java
+++ b/java/com/google/gerrit/httpd/UrlModule.java
@@ -110,7 +110,9 @@
serveRegex("^/(?:a/)?groups/(.*)?$").with(GroupsRestApiServlet.class);
serveRegex("^/(?:a/)?projects/(.*)?$").with(ProjectsRestApiServlet.class);
- filter("/Documentation/").through(QueryDocumentationFilter.class);
+ serveRegex("^/Documentation$").with(redirectDocumentation());
+ serveRegex("^/Documentation/$").with(redirectDocumentation());
+ filter("/Documentation/*").through(QueryDocumentationFilter.class);
}
private Key<HttpServlet> notFound() {
@@ -235,6 +237,19 @@
});
}
+ private Key<HttpServlet> redirectDocumentation() {
+ return key(
+ new HttpServlet() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
+ String path = "/Documentation/index.html";
+ toGerrit(path, req, rsp);
+ }
+ });
+ }
+
static void toGerrit(String target, HttpServletRequest req, HttpServletResponse rsp)
throws IOException {
final StringBuilder url = new StringBuilder();
diff --git a/java/com/google/gerrit/httpd/raw/StaticModule.java b/java/com/google/gerrit/httpd/raw/StaticModule.java
index 664d881..124ad1c 100644
--- a/java/com/google/gerrit/httpd/raw/StaticModule.java
+++ b/java/com/google/gerrit/httpd/raw/StaticModule.java
@@ -119,6 +119,8 @@
@Override
protected void configureServlets() {
+ serveRegex("^/Documentation$").with(named(DOC_SERVLET));
+ serveRegex("^/Documentation/$").with(named(DOC_SERVLET));
serveRegex("^/Documentation/(.+)$").with(named(DOC_SERVLET));
serve("/static/*").with(SiteStaticDirectoryServlet.class);
install(