Index: community/cms/engine/src/main/java/org/hippoecm/frontend/Main.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- community/cms/engine/src/main/java/org/hippoecm/frontend/Main.java	(revision 2c2a97ac35bd5710cfb0e55b304a83944c8c49da)
+++ community/cms/engine/src/main/java/org/hippoecm/frontend/Main.java	(revision 979688ea4b42493945a6efa12f9b9ecb0030d221)
@@ -29,6 +29,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.observation.EventListener;
 import javax.jcr.observation.EventListenerIterator;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
@@ -46,6 +47,7 @@
 import org.apache.wicket.core.request.handler.PageProvider;
 import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
 import org.apache.wicket.core.request.handler.RenderPageRequestHandler.RedirectPolicy;
+import org.apache.wicket.core.request.mapper.MapperUtils;
 import org.apache.wicket.core.util.resource.locator.IResourceNameIterator;
 import org.apache.wicket.core.util.resource.locator.IResourceStreamLocator;
 import org.apache.wicket.markup.html.IPackageResourceGuard;
@@ -57,6 +59,7 @@
 import org.apache.wicket.protocol.http.servlet.ServletWebResponse;
 import org.apache.wicket.request.IRequestCycle;
 import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.request.IRequestMapper;
 import org.apache.wicket.request.IRequestParameters;
 import org.apache.wicket.request.Request;
 import org.apache.wicket.request.Response;
@@ -70,6 +73,9 @@
 import org.apache.wicket.request.http.WebRequest;
 import org.apache.wicket.request.http.WebResponse;
 import org.apache.wicket.request.mapper.AbstractMapper;
+import org.apache.wicket.request.mapper.IRequestMapperDelegate;
+import org.apache.wicket.request.mapper.info.PageComponentInfo;
+import org.apache.wicket.request.mapper.info.PageInfo;
 import org.apache.wicket.request.resource.PackageResourceReference;
 import org.apache.wicket.request.resource.ResourceReference;
 import org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy;
@@ -189,6 +195,82 @@
     protected String repositoryFallbackUsername;
     protected String repositoryFallbackPassword;
 
+    private static class HidePageVersionMountMapper implements IRequestMapperDelegate {
+
+        private final IRequestMapper wrappedMapper;
+
+        public HidePageVersionMountMapper(final IRequestMapper wrappedMapper) {
+            this.wrappedMapper = wrappedMapper;
+        }
+
+        public IRequestMapper getDelegateMapper() {
+            return wrappedMapper;
+        }
+
+        private static Url getVersionedPageUrl(final Request request) {
+            Url url = request.getUrl();
+            if (request instanceof ServletWebRequest && url.getSegments().isEmpty()) {
+                HttpServletRequest httpServletRequest = ((ServletWebRequest)request).getContainerRequest();
+                HttpSession session = httpServletRequest.getSession(false);
+                if (session != null) {
+                    Url pageVersionUrl = new Url(url);
+                    PageComponentInfo pageComponentInfo = null;
+                    String queryParameterName = null;
+                    for (Url.QueryParameter queryParameter : url.getQueryParameters()) {
+                        pageComponentInfo = MapperUtils.parsePageComponentInfoParameter(queryParameter);
+                        if (pageComponentInfo != null) {
+                            queryParameterName = queryParameter.getName();
+                            break;
+                        }
+                    }
+                    if (pageComponentInfo == null || pageComponentInfo.getPageInfo().getPageId() == null) {
+                        int pageId = session.getAttribute("hippo:username") != null ? 1 : 0;
+                        pageComponentInfo = new PageComponentInfo(new PageInfo(pageId), pageComponentInfo != null ? pageComponentInfo.getComponentInfo() : null);
+                        if (queryParameterName != null) {
+                            pageVersionUrl.removeQueryParameters(queryParameterName);
+                        }
+                        pageVersionUrl.addQueryParameter(pageComponentInfo.toString(), "");
+                        return pageVersionUrl;
+                    }
+                }
+            }
+            return null;
+        }
+
+        public IRequestHandler mapRequest(final Request request) {
+            Url pageVersionUrl = getVersionedPageUrl(request);
+            if (pageVersionUrl != null) {
+                return wrappedMapper.mapRequest(request.cloneWithUrl(pageVersionUrl));
+            }
+            return wrappedMapper.mapRequest(request);
+        }
+
+        public int getCompatibilityScore(final Request request) {
+            Url pageVersionUrl = getVersionedPageUrl(request);
+            if (pageVersionUrl != null) {
+                return wrappedMapper.getCompatibilityScore(request.cloneWithUrl(pageVersionUrl));
+            }
+            return 0;
+        }
+
+        public Url mapHandler(final IRequestHandler requestHandler) {
+            final Url url = wrappedMapper.mapHandler(requestHandler);
+            if (url.getSegments().isEmpty()) {
+                for (Url.QueryParameter queryParameter : url.getQueryParameters()) {
+                    PageComponentInfo pageComponentInfo = MapperUtils.parsePageComponentInfoParameter(queryParameter);
+                    if (pageComponentInfo != null && pageComponentInfo.getPageInfo().getPageId() != null) {
+                        Url versionlessUrl = new Url(url);
+                        versionlessUrl.removeQueryParameters(queryParameter.getName());
+                        if (pageComponentInfo.getComponentInfo() != null) {
+                            versionlessUrl.addQueryParameter(new PageComponentInfo(new PageInfo(), pageComponentInfo.getComponentInfo()).toString(), "");
+                        }
+                        return versionlessUrl;
+                    }
+                }
+            }
+            return url;
+        }
+    }
 
     protected void initializeFallBackCredentials() {
         repositoryFallbackUsername = getConfigurationParameter(REPOSITORY_USERNAME_PARAM, null);
@@ -199,6 +281,8 @@
     protected void init() {
         super.init();
 
+        setRootRequestMapper(new HidePageVersionMountMapper(getRootRequestMapper()));
+
         initializeFallBackCredentials();
 
         addRequestCycleListeners();
@@ -766,9 +850,11 @@
                 throw new IllegalArgumentException("CR or LF detected in redirect URL: possible http response splitting attack");
             }
 
+/* CMS-9760 fix seems to be no longer needed
             if (url.equals("./")) {
                 url += "?";
             }
+*/
 
             super.sendRedirect(url);
         }
