Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Add .html to sling:internalRedirect

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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

Avatar

Community Advisor

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