How to implement extension-less URL's in Adobe Experience Manager(AEM)
As per the SEO best practices it is better to define extension less URL's to boost the ranking, AEM require the extension to understand and serve incoming request.This post explains the approach to achieve the extension less URL in Adobe Experience Manager(AEM)
There are two steps
- Rule Configuration Dispatcher
Remove .html extension from incoming URL with /
Append the .html while invoking the publisher for the URL's ending with /
- AEM etc/map configuration
Reverse mapping to rewrite the html URL in the pages to extension less
Forward mapping to map the incoming request to resource
This is tested in AEM 6.2 version
Apache configurations:
RewriteRule ^/$ /en/ [R=301,L]
#Mask the /content/geometrixx-outdoors path
RewriteRule ^/content/geometrixx-outdoors/(.*)(\.html)?$ /$1 [NE,L,R=301]
#Replace the .html with /
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^/(.*).html$ /$1/ [R=301,L,QSA]
#Append the .html for those URL's ending with / before sending to publisher
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^/(.*)/$ /$1.html [PT,L,QSA]
Publisher etc/map configurations:
Create a node localhost.8080(replace with required DNS and port) of type sling:Mapping under /etc/map/http or /etc/map/https based on the protocol used
Add the following property
sling:internalRedirect[] - /content/geometrixx-outdoors
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:Mapping"
sling:internalRedirect="[/content/geometrixx-outdoors]">
<redirect/>
<reverse/>
</jcr:root>