How to map urls?

江枫思渺然 提交于 2019-12-02 02:49:25

问题


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:

  1. Using CRXDE navigate to /etc/map/http.
  2. Create a new node:
  3. Type sling:Mapping
  4. This node type is intended for such mappings, though its use is not mandatory.
  5. Name localhost_any
  6. Click Save All.
  7. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!