Redirect Manager - Context Aware Redirect Configurations

Context Aware Redirect Configurations

ACS Commons Redirect Manager supports context aware configurations. Out of the box it comes with a default global configuration (/conf/global/) which is a good start to put your redirection rules:

/conf/global
    + settings
      + redirects
        + rule-1
            - source = "/content/we-retail/page1"
            - target = "/content/we-retail/page2"
            - statusCode = 302
        + rule-2
            - source = "/content/wknd/page1"
            - target = "/content/wknd/page2"
            - statusCode = 302

This requires zero configuration in your content sites. Just put your redirects in the global list, replicate them to publish and they will work!

However, there can be cases where you want to have different configurations for each site, for example, we-retail and wknd would have their own tables of redirects, any other site will fallback to /conf/global :

Redirects for /content/we-retail

/content/we-retail
    + jcr:content
      - cq:conf = "/conf/we-retail"

/conf/we-retail
    + settings
      + redirects
        + rule-1
            - source = "/content/we-retail/page1"
            - target = "/content/we-retail/page2"
            - statusCode = 302

Redirects for /content/wknd

/content/wknd
    + jcr:content
      - cq:conf = "/conf/wknd"

/conf/we-retail
    + settings
      + redirects
        + rule-1
            - source = "/content/wknd/page1"
            - target = "/content/wknd/page2"
            - statusCode = 302

Redirects for other sites

# sites that don't have cq:conf will fallback to this configuration
/conf/global
    + settings
      + redirects
        + rule-1
            - source = "/content/we-retail/page1"
            - target = "/content/we-retail/page2"
            - statusCode = 302

Configuration Resolution

AEM performs a lookup based on the content and it’s contextual cq:conf property to find the appropriate configuration. If cq:conf is not set then /conf/global is used as a fallback.

Example:

  1. User requests /content/we-retail/page1
  2. AEM goes up the content tree until a resource with the cq:conf property is found: /content/we-retail/jcr:content@cq:conf
  3. Check if a configuration resource exists at the path the property points to: /conf/we-retail
  4. Check if the redirect configuration exists below the configuration resource: /conf/we-retail/settings/redirects
  5. Use /conf/global as fallback pat

Customizing storage path

The default configuration bucket and node name are settings and redirects respectively which means that redirect configurations will be stored in a settings/redirects node relative to its /conf parent, e.g

/conf/global/settings/redirects
/conf/we-retail/settings/redirects
/conf/wknd/settings/redirects
...

Notice that all of these configurations end with settings/redirects. This can be changed in the OSGi configuration of com.adobe.acs.commons.redirects.filter.RedirectFilter

OSGi Configuration