Expand my Community achievements bar.

URL in AEM without .html extension

Avatar

Level 1

Hi everyone, 
I am new to AEM and working on an issue where I need to make the url to work without having the .html extension at the end.
can anyone please guide me on this.

Thanks,

karthik.

4 Replies

Avatar

Community Advisor

Hi @KannaKarthi 

You could do it in multiple ways, you can use dispatcher redirects, resource resolver mapper, configuration, enable etc/map configuration etc.

 

mapping /content/mysite/mypage.htm → /mypage.html- extensionless URLs 

  • /content/mysite/en.html → /
  • /content/mysite/en/homepage.html → /homepage/
  1. Enable etc/map configuration in AEM
  2. Use reverse mapping to rewrite HTML URLs without an extension
  3. Use forward mapping to map incoming requests to resources 
     

 

 

Avatar

Community Advisor

@KannaKarthi 

 

Step-1 : Please enable Debug logs on dispatcher to understand how URLs are being rewritten. Baseline variables are predefined in the file conf.d/variables/global.vars. These default variables, like DISP_LOG_LEVEL, REWRITE_LOG_LEVEL, etc., ensure non-null values. Edit conf.d/variables/global.vars to modify values

Define DISP_LOG_LEVEL info
Define REWRITE_LOG_LEVEL trace2

The rewrite logs for AEMaaCS SDK are written in /etc/httpd/logs/httpd_error.log

Sample logs:

[Thu Aug 31 10:46:08.251355 2023] [rewrite:trace2] [pid 360:tid 140516768209720] mod_rewrite.c(493): [client 172.17.0.1:41744] 172.17.0.1 - - [localhost/sid#7fcc9c28a588][rid#7fcc9bb75fc0/initial] init rewrite engine with requested uri /en.html
[Thu Aug 31 10:46:08.251441 2023] [rewrite:trace2] [pid 360:tid 140516768209720] mod_rewrite.c(493): [client 172.17.0.1:41744] 172.17.0.1 - - [localhost/sid#7fcc9c28a588][rid#7fcc9bb75fc0/initial] rewrite '/en.html' -> '/content/wknd/us/en.html'
[Thu Aug 31 10:46:08.251453 2023] [rewrite:trace2] [pid 360:tid 140516768209720] mod_rewrite.c(493): [client 172.17.0.1:41744] 172.17.0.1 - - [localhost/sid#7fcc9c28a588][rid#7fcc9bb75fc0/initial] forcing '/content/wknd/us/en.html' to get passed through to next API URI-to-filename handler

Source: https://techrevel.blog/2023/09/01/aem-dispatcher-filters-ignoreurlparams-virtualhosts-rewrites/

 

Step-2: Update the rewrite rule in the file specific to your app. The file would be present in conf.d/rewrites

 

Step-3: Check with your team, if they are using Sling Mapping for URL shortening etc. If yes, please follow the section " Enable etc/map configuration in AEM(Publisher)" on https://www.albinsblog.com/2018/04/how-to-implement-extension-less-urls-in-adobe-experience-manager.... 

Else, define the rewrite rules as defined in "Apache configurations" on above link.

 

 


Aanchal Sikka