AEM | how to remove ".html" extension for URLs | Community
Skip to main content
April 29, 2024
Solved

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

  • April 29, 2024
  • 4 replies
  • 2241 views

Hi Everyone,

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by sravs

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/deploying/resource-mapping

 

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 -->

 

4 replies

sravs
Community Advisor
sravsCommunity AdvisorAccepted solution
Community Advisor
April 29, 2024

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/deploying/resource-mapping

 

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 -->

 

Jagadeesh_Prakash
Community Advisor
Community Advisor
April 29, 2024

@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]

 

 

aanchal-sikka
Community Advisor
Community Advisor
April 29, 2024

@kanthsri 

 

Please have a look at the discussion on https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/after-sling-mappings-config-to-remove-html-redirection-301-of/m-p/393027

 

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

Aanchal Sikka
Harwinder-singh
Community Advisor
Community Advisor
April 29, 2024

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