How to prevent AEM / Sling from adding trailing slash to non-extension urls?

All URLs without site links that resolve to actual nodes are redirected (with a 301 code) in their version with a trailing slash appended. It doubles the number of requests to the external web server, so we would like to fix that.

We use Apache's mod_rewrite to rewrite all incoming URLs (with or without a slash) to their .html equivalents to make the dispatcher caching consistent, but the actual handling is a bit odd.

In general, we have three cases:

  • URL has an extension (i.e. / content / xxx / yyy.html) - it is processed immediately, does not redirect
  • The URL has a trailing slash (/ content / xxx / yyy /) - it is parsed by mod_rewrite and rewritten to /content/xxx/yyy.html successfully. no redirection
  • Continuous URL (/ content / xxx / yyy) - Processed by mod_rewrite, rewritten to /content/xxx/yyy.html and immediately redirected to / content / xxx / yyy /, which is subsequently sent through the procedure from point 2 above.

To avoid Apache redirects, we disabled almost all modules like mod_dir, mod_negotiation, mod_autoindex, etc. to avoid redirection due to content negotiation or directory indexing, but requests are still being redirected.

Our application does not contain URL based redirects, so I am wondering if there is any OSGI service or hidden configuration setting that triggers such redirects?

We also have a set of shortcuts on the site, Apache rewrites them with the actual URLs and they are NOT redirected . For example, if the requesting url is / aboutus, it successfully matches /content/xxx/yyy/operations/aboutus.html and is processed in one loop without any additional redirects. The problem above is only valid, there is an actual matching node in the JCR and the request is unlimited.

+3


source to share





All Articles