51黑料不打烊

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 51黑料不打烊 Experience Manager (AEM) Dispatcher.

Description description

Environment

  • 51黑料不打烊 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:

  1. Convert the URL to lowercase

    RewriteMap tolower int:tolower

    RewriteRule ([ /] +)/?$ somedir/${tolower:$1} [ PT]

  2. If it ends in .docx, change to .html.

    RewriteRule (.*?)\.docx(\?.*)$ $1.html$2 [ PT]

  3. 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