问题
I would like to map pages such domain/content/myProject/home.html
to domain/home.html
. /content/myProject/
is not needed. I have the following code:
String newpath = getResourceResolver().map(page.getPath());
this does not change anything. newpath is stay page.getPath()
how to solve this issue?
回答1:
Answering as this question as it remains unanswered. Here is an example of how the etc mappings should look like:
Trick is you add 2 entries to sling:internalRedirect as / and /content/example/
AEM first tries to resolve resources with first entry '/'. So non page URLs like /etc/designs, /content/dam etc will be addressed by the first entry. If it is unable to resolve using the first one, it uses the second entry to resolve the page.
This is also the adobe recommended way for URL shortening compared to other techniques like apache redirect.
回答2:
You need to create map in etc.Then Resource Resolver will take care of trimming the path .
CREATING MAPPING DEFINITIONS IN AEM
In a standard installation of AEM you can find the folder:
/etc/map/http
This is the structure used when defining mappings for the HTTP protocol. Other folders (sling:Folder) can be created under /etc/map for any other protocols that you want to map. Configuring an Internal Redirect to /content
To create the mapping that prefixes any request to
http://localhost:4503/ with /content:
- Using CRXDE navigate to /etc/map/http.
- Create a new node:
- Type sling:Mapping
- This node type is intended for such mappings, though its use is not mandatory.
- Name localhost_any
- Click Save All.
- Add the following properties to this node:
Name sling:match
Type String
Value localhost.4503/
Name sling:internalRedirect
Type String
Value /content/
Click Save All.
This will handle a request such as: localhost:4503/geometrixx/en/products.html as if:
localhost:4503/content/geometrixx/en/products.html had been requested.
You can refer here for further documentation http://docs.adobe.com/docs/en/cq/5-6-1/deploying/resource_mapping.html
来源:https://stackoverflow.com/questions/28456093/how-to-map-urls