问题
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