Removing .html extension at dispatcher, sling:mapping, and vanity URLs conflict
Hi,
I am working on a website in which we must remove the .html from the url, allow vanity URLs and map content to /content/<application>. Before the dispatcher, mod_rewrite is removing the .html from the URLs with the following rules - (e.g. changes /us/en/home.html to /us/en/home/:
# Handle request with no slash and no extension
RewriteCond %{REQUEST_URI} !^/content/dam/.*
RewriteCond %{REQUEST_URI} !.*\..*$
RewriteCond %{REQUEST_URI} !.*/$
RewriteRule (.*)$ $1/ [R,QSA]
# Handle requests to pages ending with .html
RewriteCond %{REQUEST_URI} !^/content/dam/.*
RewriteCond %{REQUEST_URI} .*.html$
RewriteCond %{REQUEST_URI} !^/health/.*
RewriteRule (.*).html$ $1 [R,QSA]
# Handle requests to pages ending with a trailing slash
RewriteCond %{REQUEST_URI} !^/content/dam
RewriteCond %{REQUEST_URI} .*/$
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^([^.]+?)/?$ $1.html [PT,L,QSA]
This causes a problem for Vanity URLs as it is rewriting to .html on the last rule above (we don't have .html in our vanity URLs). Also our sling:mapping (/etc/map) is rewriting to /content/
Vanity Path Precendence does not work due to my rewrite at the dispatcher. We will have authors and need to handle this dynamically and do not want to hardcode rules for the vanity urls in /etc/map and Apache mod_rewrite. Does anyone know how to solve this with AEM or any custom solutions to account for these rules? Any ideas?