there are always multiple options to a problem in Sling. If you look at the topic "URL rewriting" it has two dimensions:
- outbound - e.g. shorten links
/content/path/en/about.html
to /en/about/
- inbound - e.g. map an inbound request from
/en/about/
to a resoure request /content/path/en/about.html
Outbound:
URL rewriting is usually be done outbound by a LinkRewriter/TransformerFactory.
In theory, you could also change your component to render differently or change your content. But that's not recommended.
To apply a Transformer you can use
- /etc/map mapping (recommended), referred to as Mapping Map Entries [1]
- enhanced mapping allowing for complex rules, also for regex-based rules
- allows for different mapping per domain or protocol
- can ensure complete externalization of links
- ResourceResolver Map Entries [1]
- traditional mapping, very simple rules only
- Does not take domain or protocol into account
- requires resolver restart on change (can be expensive for large production environments)
- Custom TransformerFactory
- full power to change all links on the way out based on Sax+custom rules
Inbound:
Your inbound requests can be rewritten or mapped on Sling or at infrastructure levels before (Apache HTTPD mod_rewrite or CDN s.a. Akamai)
- Apache HTTPD mod_rewrite (recommended for production) - modify the request before it gets forwarded to the Dispatcher module. Recommended as it allows for enhanced security as well as for proper and simple caching and de-caching rules
- Sling - usually not for production, as caching might become difficult
- /etc/map
- ResourceResolver
- RequestFilter [2]
- NonExistingResource servlet
- CDN: same as mod_rewrite. Inbound manipulation before the request reaches the Dispatcher
HTH
[1]
https://docs.adobe.com/docs/en/aem/6-2/deploy/configuring/resource-mapping.html
[2]
https://sling.apache.org/documentation/the-sling-engine/filters.html
[3]
https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html