.html removal for live url

srikanthp689160

25-04-2019

Hi,

We have a requirement to remove .html from end user urls while retaining cacheability.

The approach which we followed is

  1. Checked Strip HTML Extension under Day CQ Link Checker Transformer in Felix console.
  2. Created a sling mapping with sling:internalRedirect as /content/mycompany/amer/us/en/xyz/$1.html, $1.html (string array)
  3. Added below configurations to create cache at dispatcher level

RewriteCond %{REQUEST_FILENAME} !.

RewriteCond %{REQUEST_METHOD} ^GET$

RewriteCond %{HTTP_ACCEPT} ^.html.$

RewriteRule ^([^.][^./]) # .)?$ $1.html$2 [PT,QSA]

The issues which we are facing are

  1. Images with extensions like .jpg and .png are not loading.
  2. Unable to open pages under /etc/replication for example Agents on Publish, Agents on Author, Activate Tree.
  3. With the above dispatcher configurations, cache gets created but custom rewrite rules are not working.

            for example thesetype of rules are not working   RewriteRule  ^/(.*)$ /content/mycompany/amer/us/en/xyz/$1 [PT]

Is there a way to achieve stripping html for few sites and retain for others without checking option Strip HTML Extension under Day CQ Link Checker Transformer in Felix console?

Any help on this is highly appreciated.

Thanks & Regards,

Srikanth Pogula

Accepted Solutions (1)

Accepted Solutions (1)

antoniom5495929

25-04-2019

Hi,

in my experience, if you need to rewrite the outcoming links  in order to strip the extension and then cache the page with the extension in order to use the standard configuration of the flush Agent, you just only need to apply the strip configuration from the Link Checker Transformer configuration and apply a rewrite at the apache level in order to add the .html extension for the incoming request.

In that way the extension is applied in the cache and you don't need to change nothing into the Flush Agent.

Let me know if you need some other info.

Thanks,

Antonio

Answers (3)

Answers (3)

Gaurav-Behl

MVP

25-04-2019

There are several solutions but that depends on your "requirements". You'll find a lot of threads in this forum itself -

You'd have to do a lot of custom effort to strip .html in web server then map it back to content using sling mappings for sling to resolve it. Post that, you'd have to write custom flush agents to manipulate the path where you plan to utilize it.

couple of links:

Adobe CQ/Adobe AEM: How to Remove .html extension from URL in CQ Or How to Implement New Rewriter Pi...

Remove .html

Removing .html extension at dispatcher, sling:mapping, and vanity URLs conflict

apache - Strip HTML extension from outgoing URL - Stack Overflow

srikanthp689160

25-04-2019

Hi Gaurav,

The goal is to have html free urls in our application and cache needs to be created and it must be auto flushed when content is activated.

Any pointers would be helpful.

Gaurav-Behl

MVP

25-04-2019

Could you explain your requirements/use case that you're trying to achieve?

Technically it could be done but it depends on your use case and your setup.