Search code examples
url-rewritingadobeaem

.html is not getting appended in the URL in new AEM set-up


We are setting up AEM for the first time and we are facing the issue that the URLs fail to have .html in it. from example if the URL should be

http://dev.alfaromeousa.com/cars/usa/en.html

it actually coming as

http://dev.alfaromeousa.com/cars/usa/en/

For temporary solution we added the below rewrite rule

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !^.*.html$
RewriteRule ^(.*)$ $1.html [L,R=301] 

But it fails when the URL are like

http://dev.abc.com/cars/usa/

by adding an .html. So URL turns into

http://dev.abc.com/cars/usa/.html.

Can anyone please help me with figuring out if i missed out something in set-up or did anything wrong


Solution

  • The issue was resolved with the below rewite rule :

    RewriteCond %{REQUEST_URI} !^/aemusaerror/(.*) [NC]
    RewriteCond %{REQUEST_URI} !^/content/dam(.*) [NC]
    RewriteCond %{REQUEST_URI} !^/etc/designs(.*) [NC]
    RewriteCond %{REQUEST_URI} !^/vl/(.*)json [NC]
    RewriteCond %{REQUEST_URI} !^/timestamp [NC]
    RewriteCond %{REQUEST_URI} !(.*)\.[a-zA-Z0-9-]+$
    RewriteCond %{REQUEST_URI} !^/renderer/(.*) [NC]
    RewriteRule ^(/.*)$ /content/alfausa/en$1.html [P,L]