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
apache mod-rewrite aem cq5 sling


source to share


No one has answered this question yet

Check out similar questions:

24
mod_rewrite: remove trailing slash (just one!)
3
How do I remove the trailing slash for "/folder/index.html" when "index.html" is removed?
2
Working with trailing slash in htaccess
1
mod_rewrite rewrite rule to redirect browser url when trailing slash is missing
0
How can I remove anything starting with the '?' after the end of the slash?
0
mod_rewrite: remove trailing slash (just one!)
0
Slash issues in Amazon ELB and Apache
0
How can I remove the trailing slash from a URL using a rewrite mechanism?
-1
Apache redirect 301 remove trailing slash only from specific urls



All Articles
Loading...
X
Show
Funny
Dev
Pics