Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

AEM | how to remove ".html" extension for URLs

Avatar

Level 1

Hi Everyone,

how to remove the ".html" extension from all links within the abc.com top navigation.

1 Accepted Solution

Avatar

Correct answer by
Level 8

Hi @Kanthsri , you can use resource resolver to map the URLs without html extension.

 

refer https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/dep...

 

Or if you want to remove the .html extension for particular component you can use the snippet like below in your component html.

 

${'path/page.html' @ extension}
<!-- outputs: path/page -->

 

View solution in original post

4 Replies

Avatar

Correct answer by
Level 8

Hi @Kanthsri , you can use resource resolver to map the URLs without html extension.

 

refer https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/dep...

 

Or if you want to remove the .html extension for particular component you can use the snippet like below in your component html.

 

${'path/page.html' @ extension}
<!-- outputs: path/page -->

 

Avatar

Community Advisor

@Kanthsri  hope you are looking for a dispatcher rule to remove .html from the url. Try below code

 

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)\.html$ /$1 [NC,L]

 

 

Avatar

Community Advisor

@Kanthsri 

 

Please have a look at the discussion on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/after-sling-mappings-confi...

 

Prefer using Sling mappings to remove .html extensions/URL shortening from HTML content


Aanchal Sikka

Avatar

Community Advisor

@Kanthsri  You can strip off .html at the dispatcher level.