Add .html to sling:internalRedirect | Community
Skip to main content
Level 2
March 31, 2023
Solved

Add .html to sling:internalRedirect

  • March 31, 2023
  • 2 replies
  • 1557 views

Only on author instance I want to do mapping for URLs without .html. I have written the regex for sling:match. My use case is like, when a user hits URL like /content/we-retail/en is should redirect to /content/we-retail/en.html . ie, I want to append .html to whichever path the user is hitting, if it doesn't have .html and also I want to do this only for AEM author.

 

Thanks in advance.

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 Rohit_Utreja

Hi @vaishnav_s ,
You can write a Rewrite rule in AEM dispatcher. Something as mentioned below.

RewriteRule ^/(.*)$  /$1.html [R=301,L]

 If you want to handle it within AEM, Apache Sling Resource Resolver Factory can be used.

Please refer below article for more details.

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

2 replies

Rohit_Utreja
Community Advisor
Rohit_UtrejaCommunity AdvisorAccepted solution
Community Advisor
March 31, 2023

Hi @vaishnav_s ,
You can write a Rewrite rule in AEM dispatcher. Something as mentioned below.

RewriteRule ^/(.*)$  /$1.html [R=301,L]

 If you want to handle it within AEM, Apache Sling Resource Resolver Factory can be used.

Please refer below article for more details.

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

JeevanRaj
Community Advisor
Community Advisor
March 31, 2023

You can use etc mapping to map incoming requests to proper resource. Check out this article.

https://medium.com/tech-learnings/how-to-implement-extension-less-urls-in-aem-a3136c71b232