URL in AEM without .html extension | Community
Skip to main content
New Participant
May 20, 2024

URL in AEM without .html extension

  • May 20, 2024
  • 4 replies
  • 2594 views

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.

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

    4 replies

    Rohan_Garg
    New Participant
    May 20, 2024

    @albinis1's blog is the one stop solution for this requirement -  How to implement extension-less URL’s in AEM

    aanchal-sikka
    New Participant
    May 20, 2024

    @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.html 

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

     

     

    Aanchal Sikka
    Manu_Mathew_
    New Participant
    May 20, 2024

    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