Skip to main content
Level 2
March 31, 2023
Resuelto

Add .html to sling:internalRedirect

  • March 31, 2023
  • 2 respuestas
  • 1587 visualizaciones

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.

Este tema ha sido cerrado para respuestas.
Mejor respuesta de 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 respuestas

Rohit_Utreja
Community Advisor
Rohit_UtrejaCommunity AdvisorRespuesta
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

BR, Rohit
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