title: Spring, redirect from index.html to root
body: <p>Now, when I open root <code>/</code> URL I see <code>index.html</code> content, but URL is <code>/</code></p>
  
  <p>And when I open <code>/index.html</code> I see same, and URL is <code>/index.html</code></p>
  
  <p>I need to see same URL when I open <code>/</code> and <code>/index.html</code>, so I thought that I need to add a redirect:</p>
  
  <pre><code>registry
      .addViewController("/").setViewName("forward:/index.html");
      .addRedirectViewController("/index.html", "/");
  </code></pre>
  
  <p>but it seems to circular calls.</p>
  
  <p>How can I do, that <code>/</code> and <code>/index.html</code> are show same content from same URL <code>/</code> with my config?</p>
  
  <p>Part of webapp directory:</p>
  
  <p><a href="https://i.stack.imgur.com/uyyfu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uyyfu.png" alt="enter image description here"></a></p>
  
  <p>Part of config:</p>
  
  <pre><code>@Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry
          .addResourceHandler("/**")
          .addResourceLocations("/webapp/")
          .setCachePeriod(604800)
          .resourceChain(true)
          .addResolver(new GzipResourceResolver())
          .addResolver(new PathResourceResolver());
  }
  
  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
      registry
          .addViewController("/").setViewName("forward:/index.html");
  }
  </code></pre>
  
  <p><strong>UPD</strong></p>
  
  <p>I tried suggestion from @Asgeirr answer before ask a question, but I get ERR_TOO_MANY_REDIRECTS.</p>
  
  <p>Maybe problem in my server config?</p>
  
  <pre><code>@Bean
  public Server server(ApplicationContext rootCtx){
      Server server = new Server(serverPort);
  
      HttpConfiguration httpConfig = new HttpConfiguration();
      httpConfig.addCustomizer(new SecureRequestCustomizer());
  
      ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
  
      httpConnector.setPort(serverPort);
      httpConnector.setIdleTimeout(connectorIdleTime);
      server.setConnectors(new Connector[]{httpConnector});
  
      ServletContextHandler apiHandler = new ServletContextHandler();
      apiHandler.setContextPath("/");
      apiHandler.setResourceBase(".");
  
      HashSessionIdManager idManager = new HashSessionIdManager();
      server.setSessionIdManager(idManager);
      HashSessionManager manager = new HashSessionManager();
      manager.setMaxInactiveInterval(sessionTimeout);
      SessionHandler sessions = new SessionHandler(manager);
      apiHandler.setHandler(sessions);
  
      AnnotationConfigWebApplicationContext webCtx = new AnnotationConfigWebApplicationContext();
      webCtx.setServletContext(apiHandler.getServletContext());
      webCtx.register(WebConfiguration.class);
      webCtx.setParent(rootCtx);
      webCtx.refresh();
  
      // Adding gzip compression
      FilterHolder holder = new FilterHolder(GzipFilter.class);
      holder.setInitParameter("deflateCompressionLevel", "9");
      holder.setInitParameter("minGzipSize", "0");
      holder.setInitParameter("mimeTypes", "text/html,text/css,image/svg+xml,text/xhtml,text/plain,text/xml," +
              "text/javascript,application/xhtml+xml,application/xml,application/javascript,application/json");
      apiHandler.addFilter(holder, "/*", EnumSet.of(DispatcherType.REQUEST));
  
      CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
      characterEncodingFilter.setEncoding("UTF-8");
      characterEncodingFilter.setForceEncoding(true);
      apiHandler.addFilter(new FilterHolder(characterEncodingFilter), "/*", EnumSet.allOf(DispatcherType.class));
      apiHandler.addServlet(new ServletHolder(new DispatcherServlet(webCtx)), "/");
  
      HandlerCollection handlerCollection = new HandlerCollection();
      handlerCollection.addHandler(apiHandler);
      server.setHandler(handlerCollection);
  
      return server;
  }
  </code></pre>
  
  <p>Network log, when I call <code>/index.html</code></p>
  
  <p><a href="https://i.stack.imgur.com/juSvP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/juSvP.png" alt="enter image description here"></a></p>