Hi @aryaba1,
Here's what usually works well in real-world setups:
1. AEM Side - Resource Resolver Config
In Author and Publish, configure the OSGi service:
Apache Sling Resource Resolver Factory (org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl)
Make sure these values are set:
resource.resolver.mapping=["/content/mysite/", "/"]
resource.resolver.enable.extensionless.paths=true
This makes sure AEM can resolve URLs like /about to /about.html internally without needing to see the extension.
2. Apache Dispatcher - Rewrite Rules
On the Dispatcher side, use Apache rewrite rules to serve .html content when an extensionless URL is requested:
# Rewrite extensionless URLs to .html (if not requesting a file)
RewriteCond %{REQUEST_URI} !\.[a-zA-Z0-9]+$
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [PT,L]
This lets users access /about, and Apache will internally rewrite it to /about.html without changing the URL in the browser.
3. Internal links & clientlibs
This is often the tricky part.
Option A: Let AEM output .html, but rewrite at the server
-
Keep using .html in links (/about.html)
-
Apache rewrites them so users see /about
-
Simple, works well with clientlibs
Option B: Remove .html in authoring/rendering
-
Use a custom HTL helper or Sling Rewrite Transformer to strip .html from generated links
-
Riskier unless you're confident in custom link management (especially with clientlibs, language copies, etc.)
Most of us go with Option A to avoid breaking paths.
4. Sling Mappings (Optional, for domain-level rewrite)
If you're doing domain-to-path mapping (eg. map https://mysite.com to /content/mysite), then add /etc/map.publish/https nodes like:
/etc/map.publish/https/mysite.com → /content/mysite
On AEMaaCS, use URL Mapping Rules instead, since /etc/map is restricted.
References: