I have used these mapping on CQ 5.6.1 and they seem to work. Please find JSON exported from my instance:
{
"jcr:primaryType": "sling:OrderedFolder",
"home": {
"sling:internalRedirect": "/content/geometrixx/en.html",
"sling:match": "localhost.4503/$",
"jcr:primaryType": "sling:Mapping",
},
"localhost.4503": {
"sling:internalRedirect": "/content/geometrixx/en",
"jcr:primaryType": "sling:Mapping",
"redirect": {
"sling:internalRedirect": [
"/content/geometrixx/en/$1",
"/$1"
],
"sling:match": "(.+)$",
"jcr:primaryType": "sling:Mapping",
}
}
}
The only change I've made is the port separator in the first sling:match
column - I have changed it form colon to a dot. Just to be sure we're working on the same configuration, I've created a CQ package containing my config.
This configuration makes 3 things:
- When user requests
http://localhost:4503/
they will be redirected to/content/geometrixx/en.html
- When user requests
http://localhost:4503/products.html
(or any other page from the/content/geometrixx/en
subtree) they will be redirected to/content/geometrixx/en/products.html
. - All paths in
<a>
,<img>
and<form>
tags will be mapped to their short version, eg.:
<a href="/content/geometrixx/en/products.html">Products</a>
will be rewritten to
<a href="/products.html">Products</a>
About your second question - Sling mappings doesn't allow to redirect user to the mapped version of the URL. Geometrixx site uses BrowserMap library, which (amongst other things) redirect user to the shortened version of the URL using JavaScript. That's why entering following URL:
http://locahost:4503/content/geometrixx/en/products.html
will redirect you to to /products.html
a second after the page is loaded.