Quote of the Day
" Train your mind to see the good in every situation "
What is URL shortening (or shorthand URL)?
A URL shortening (or shorthand URL) is a way to make a long, complicated web address shorter and easier to share.
Instead of sharing a long URL like:
https://www.colibra.com/content/weretail/us/en/products/womens/shoes.html
- The Vanity URL is based on the page, not the domain.
- Vanity URLs work on both Author and Publish instances.
- In the JCR repository, when a content author sets a Vanity URL for a page, AEM stores it as a property inside the page’s
jcr:contentnode: - For example,
/content/wknd/us/en/author-info/jcr:content. sling:vanityPath = "/author-info"
- AEM provides an internal resource at:
- /libs/granite/dispatcher/content/vanityUrls
- This path is part of AEM’s Granite UI framework and is responsible for exposing vanity URL mappings.
- Node, sling:resourceType = granite/dispatcher/components/vanityUrls
- This means that when the resource is requested, AEM uses the component located at: /libs/granite/dispatcher/components/vanityUrl to render the response.
- When you open this path in a browser (e.g.,
http://localhost:4502/libs/granite/dispatcher/content/vanityUrls.html), AEM dynamically generates response. - This response contains all the registered vanity URL mappings across the repository (collected from
sling:vanityPathproperties).
1. Saving the Vanity URL
- In the page node (/content/wknd/us/en/author-info/jcr:content), AEM adds a property:
sling:vanityPath = "/author-info"
At this point, if we check the /vanityUrls.html response, we’ll see our vanity mapping, which confirms it’s saved.
- When hit
http://localhost:4502/author-info
sling checks its vanity path mappings.
If a match is found → it traverses the mapping and internally redirects to the actual page path (/content/wknd/us/en/author-info).
On the Dispatcher / Web Server, sometimes the page cannot be accessed using the configured Vanity URL.
Let’s see how we can resolve such issues:
Step 11: To allow Vanity URLs on Dispatcher
We need to add the /vanity_urls section inside the dispatcher.any file. This section allows the dispatcher to resolve Vanity URLs. Here, we have to define three properties:
/url→ This property points to the service that returns all the available Vanity URLs configured in AEM./file→ Dispatcher stores these Vanity URL mappings in the specified file. This allows the dispatcher to frequently check and resolve Vanity URLs without calling AEM every time./delay→ This defines the time interval (in seconds) between consecutive calls that the dispatcher makes to AEM to refresh the Vanity URL list.
-
Easy to remember – Short and clean links are more user-friendly.
-
Author controlled – Content authors can manage URLs directly from page properties.
-
Marketing friendly – Perfect for campaigns, landing pages, and promotional content.
Disadvantages of Vanity URLs
-
Performance impact – Vanity URLs are resolved at runtime. If you configure thousands of vanity URLs or sling mappings, it can become an expensive operation in terms of resources.
-
Dispatcher setup required – Vanity URLs must be enabled and properly configured in the dispatcher.
-
Not scalable for bulk usage – If many URLs need to be shortened, other approaches like Apache rewrite rules or URL mapping may perform better.