Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Shortening URLs in AEM | AEM Community Blog Seeding




Shortening URLs in AEM by JUAN AYALA


Let’s face it, AEM URLs are ugly! Shortening them has been a requirement in every single AEM Sites implementation I have worked on.

Why do clients want shorter, optimized URLs? First of all, less complicated URLs are more user friendly. They are easy for site visitors to type, clearer to read so a visitor is confident they are going to a relevant page, and less prone to user error when copy/pasting or retyping. From an SEO perspective, Google and other search engines can crawl a site more easily when the site structure (subfolders are used well) is clear and the URLs are easy to read without a ton of unnecessary symbols or parameters.

Here is a typical AEM URL:

Instead of that, we would shorten the URL to:

Or assume en is the default:

Or remove the extension:

Unfortunately, there is no single configuration or feature that shortens URLs. Instead, several things come together. Let's cover some terms first.

Outgoing URLs (aka mapping)
Outgoing URLs are the ones getting rendered out and sent to the browser. They can exist in thecustomer

HTML markup as anchor hrefs, form actions, or image sources. Before the AEM publisher sends back the requested page it will need to call ResourceResolver.map(String resourcePath) on all of the long URLs to map them to their short-form.

Incoming URLs (aka resolving)
When the user clicks on one of those short URLs, the browser will start a request that goes back to the dispatcher first. Then, it gets proxied back to the AEM publisher. The publisher will need to call ResourceResolver.resolve(String absPath) to resolve that URL back to its long-form.

Project Archetype
Now that we know the difference between mapping and resolving, let's take a look at the AEM project archetype. I love the project archetype. It is an excellent source of best practice examples that is constantly updated. Over the past few years, the configurations to handle short URLs have been added. I will point them out to you.

Read Full Blog

Shortening URLs in AEM


Please use this thread to ask the related questions.

Kautuk Sahni
1 Reply


Level 2

Hi @kautuk_sahni ,

I am able to remove the extension ".html" but the internal remapping is not working. Hence, the pages are breaking without  ".html".

It will be great if you can elaborate part : Challenge #2 - Extensionless URLs 

from the Blog https://blog.3sharecorp.com/shortening-urls-in-aem