How to redirect the pages to their alias URLs in AEM?

喜夏-厌秋 提交于 2020-06-01 05:07:27

问题


We are planning to use sling:alias property for the translated pages through language copy so that the translated pages could be accessible through the translated URLs.

For e.g.

English page- /content/site/en/test-page

Language copy- /content/site/es/test-page - It has the property sling:alias (página de prueba)

Alias URL- /content/site/es/página de prueba

Now we are able to access it using the alias URL but we still have links in different places that use "/content/site/es/test-page" URL. So we need a redirect rule in place so that all of these pages under /content/site/es redirect to their alias URL pages.

How can we achieve this?


回答1:


We usually implement a solution like this:

  • If a page is requested we check in the page component if the requested url is the same as resourceResolver.map(request, path) (this returns a URL with the alias path). If not, we send a permanent redirect to the alias path.
  • Links that we generate in our code all get the .map call applied (central utility class or service).
  • We also add a link rewriter that checks the same - see https://helpx.adobe.com/experience-manager/using/aem63_link_rewriter.html for a walktrough.

HTH, Oliver



来源:https://stackoverflow.com/questions/61395667/how-to-redirect-the-pages-to-their-alias-urls-in-aem

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