Convert URLs to lowercase and DOCX to HTML using Apache rewrite rules
Learn how to convert URLs to lowercase and DOCX extensions to HTML using the Apache rewrite rules in the Adobe Experience Manager (AEM) Dispatcher.
Description description
Environment
- Adobe Experience Manager
- AEM Dispatcher
Issue/Symptoms
How to use mod_rewrite
using the Apache rewrite rules in AEM Dispatcher to convert URLs to lowercase and change the DOCX extension to HTML.
Resolution resolution
To resolve this error, follow these steps:
-
Convert the URL to lowercase
RewriteMap tolower int:tolower
RewriteRule ([ /] +)/?$ somedir/${tolower:$1} [ PT]
-
If it ends in .docx, change to .html.
RewriteRule (.*?)\.docx(\?.*)$ $1.html$2 [ PT]
-
Combined rewrite
RewriteMap lowercase int:tolower
RewriteRule (.*)\.[ Dd] [ Oo] [ cC] [ xX] (\?.*)?$ ${lowercase:$1}.html$2 [ NC,R=301]
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f