Hi @nehaba4,
Since you are trying to handle URL shortening without relying on dispatcher rewrites, one common and effective way is to leverage AEM’s Sling Resource Resolver mappings (/etc/map) along with a custom redirect logic if needed.
Here are few ways you can consider doing:
Use /etc/map for Path Mapping
You can define resource resolver mappings to rewrite incoming URLs to your internal content paths.
For example:
/etc/map.publish/http/www.domain.com.us/en/testpage.html -> /content/project/us/en/home/testpage
To implement this:
-
Create a node under /etc/map.publish/http (or /etc/map depending on your setup).
-
Use a structure like this:
/etc/map.publish/http/www.domain.com (sling:Mapping node)
with properties like:
This way, AEM can resolve shortened URLs internally without dispatcher involvement.
Custom Sling Servlet or Filter
If your URL structure is dynamic and complex (for example, /testpage.html should map based on the current locale or user session), you might consider writing a custom Sling Servlet or Filter that intercepts incoming requests and internally forwards or resolves them.
This would allow you to programmatically determine the correct path based on business rules.
Vanity URLs
Another option is to use vanity URLs configured at the page level. Just be cautious about performance and uniqueness if you're planning to use it at scale.
Hope this helps!