AEMaaCS Dispatcher for multi site | Community
Skip to main content
Level 2
October 9, 2025
Solved

AEMaaCS Dispatcher for multi site

  • October 9, 2025
  • 1 reply
  • 553 views

In AEMaaCS , for a multi site setup

 

In conf.d

1. can we have a common vhost code in a seperate file and then reference it in siteA.vhost and siteB.vhost ?

2. How about having common rewrites and site specific rewrites . in which folder we should put them and how to include them in vhost ?

 

In conf.dispatcher.d

1. can we maintain site specific farms ? and how to manage it using virtualhosts.any file ?

2. how to include site specific filters , like filtersA.any inside filter.any 

3. how to include site specific cache rules , like including siteACache.any  in site specific farm file 

Best answer by SantoshSai

Hi @vishnura5,

Here’s how you can structure a multi-site Dispatcher setup in AEM as a Cloud Service (AEMaaCS).
I’ll break it down by conf.d (Apache HTTPD layer) and conf.dispatcher.d (Dispatcher configs).

In conf.d (Apache vhost layer)

  1. Common vhost code

    • Yes, you can absolutely put shared logic (like SSL, headers, logging, or other boilerplate config) into a separate include file.

    • Example:

      # conf.d/includes/common_vhost.conf <IfModule mod_headers.c> Header always set X-Frame-Options "SAMEORIGIN" </IfModule> Then in each site vhost: Include conf.d/includes/common_vhost.conf
  2. Common vs. site-specific rewrites

    • Put global rewrites under something like conf.d/rewrites/global_rewrite.rules.

    • Put site-specific rewrites under conf.d/rewrites/siteA_rewrite.rules, siteB_rewrite.rules.

    • Reference them in each vhost file:

      # Inside siteA.vhost Include conf.d/rewrites/global_rewrite.rules Include conf.d/rewrites/siteA_rewrite.rules

In conf.dispatcher.d (Dispatcher layer)

  1. Site-specific farms

    • Yes, you can maintain separate farm files per site, e.g.:

      • conf.dispatcher.d/available_farms/siteA_farm.anyconf.dispatcher.d/available_farms/siteB_farm.any

    • Then symlink them into enabled_farms/.

    • Use the virtualhosts section in each farm to match requests for that site:

      /virtualhosts { "/sitea.domain.com/*" "/sitea/*" }
  2. Site-specific filters

    • Create files like filtersA.any, filtersB.any.

    • In your main filter.any you can include them:

      $include "filtersA.any" $include "filtersB.any"
  3. Site-specific cache rules

    • Same approach. Create siteACache.any, siteBCache.any.

    • In each farm file, reference its own cache rules:

      /cache { /rules { $include "../cache/siteACache.any" } }

Recommended Folder Structure

conf.d/
 ├─ available_vhosts/
 │   ├─ siteA.vhost
 │   ├─ siteB.vhost
 │   └─ common_vhost.conf
 ├─ rewrites/
 │   ├─ global_rewrite.rules
 │   ├─ siteA_rewrite.rules
 │   └─ siteB_rewrite.rules

conf.dispatcher.d/
 ├─ available_farms/
 │   ├─ siteA_farm.any
 │   ├─ siteB_farm.any
 ├─ filters/
 │   ├─ filter.any   (includes all site filters)
 │   ├─ filtersA.any
 │   └─ filtersB.any
 ├─ cache/
 │   ├─ siteACache.any
 │   └─ siteBCache.any

This way you keep common logic reusable, and still have clean separation for site-specific overrides.

1 reply

SantoshSai
Community Advisor
SantoshSaiCommunity AdvisorAccepted solution
Community Advisor
October 9, 2025

Hi @vishnura5,

Here’s how you can structure a multi-site Dispatcher setup in AEM as a Cloud Service (AEMaaCS).
I’ll break it down by conf.d (Apache HTTPD layer) and conf.dispatcher.d (Dispatcher configs).

In conf.d (Apache vhost layer)

  1. Common vhost code

    • Yes, you can absolutely put shared logic (like SSL, headers, logging, or other boilerplate config) into a separate include file.

    • Example:

      # conf.d/includes/common_vhost.conf <IfModule mod_headers.c> Header always set X-Frame-Options "SAMEORIGIN" </IfModule> Then in each site vhost: Include conf.d/includes/common_vhost.conf
  2. Common vs. site-specific rewrites

    • Put global rewrites under something like conf.d/rewrites/global_rewrite.rules.

    • Put site-specific rewrites under conf.d/rewrites/siteA_rewrite.rules, siteB_rewrite.rules.

    • Reference them in each vhost file:

      # Inside siteA.vhost Include conf.d/rewrites/global_rewrite.rules Include conf.d/rewrites/siteA_rewrite.rules

In conf.dispatcher.d (Dispatcher layer)

  1. Site-specific farms

    • Yes, you can maintain separate farm files per site, e.g.:

      • conf.dispatcher.d/available_farms/siteA_farm.anyconf.dispatcher.d/available_farms/siteB_farm.any

    • Then symlink them into enabled_farms/.

    • Use the virtualhosts section in each farm to match requests for that site:

      /virtualhosts { "/sitea.domain.com/*" "/sitea/*" }
  2. Site-specific filters

    • Create files like filtersA.any, filtersB.any.

    • In your main filter.any you can include them:

      $include "filtersA.any" $include "filtersB.any"
  3. Site-specific cache rules

    • Same approach. Create siteACache.any, siteBCache.any.

    • In each farm file, reference its own cache rules:

      /cache { /rules { $include "../cache/siteACache.any" } }

Recommended Folder Structure

conf.d/
 ├─ available_vhosts/
 │   ├─ siteA.vhost
 │   ├─ siteB.vhost
 │   └─ common_vhost.conf
 ├─ rewrites/
 │   ├─ global_rewrite.rules
 │   ├─ siteA_rewrite.rules
 │   └─ siteB_rewrite.rules

conf.dispatcher.d/
 ├─ available_farms/
 │   ├─ siteA_farm.any
 │   ├─ siteB_farm.any
 ├─ filters/
 │   ├─ filter.any   (includes all site filters)
 │   ├─ filtersA.any
 │   └─ filtersB.any
 ├─ cache/
 │   ├─ siteACache.any
 │   └─ siteBCache.any

This way you keep common logic reusable, and still have clean separation for site-specific overrides.

Santosh Sai
VishnuRa5Author
Level 2
October 10, 2025

@santoshsai  

thankyou verymuch , it worked.

 

Similar to having a coomon vhost configuration file , 

can we keep common code in farm files in a seperate file and reference it in siteA_farm.any and siteB_farm.any ?

SantoshSai
Community Advisor
Community Advisor
October 10, 2025

@vishnura5 

Yes - you can do the exact same thing with farm files in conf.dispatcher.d.

AEM Dispatcher configs (.any files) support the $include directive, so you can modularize your farms just like you did with vhosts.

  1. Create a shared file for common config
    For example:

    conf.dispatcher.d/farms/common_farm_parts/common_farm_base.any

    Inside it you might have things that are identical across all farms, such as:

    /renders { /0001 { /hostname "localhost" /port "4503" } } /cache { /docroot "/mnt/var/www/html" /allowAuthorized 0 }
  2. Reference it inside each site-specific farm
    Example for siteA_farm.any:

    /siteA_farm { $include "../common_farm_parts/common_farm_base.any" /virtualhosts { "/sitea.domain.com/*" "/sitea/*" } /filters { $include "../filters/filtersA.any" } /cache { $include "../cache/siteACache.any" } }

    Example for siteB_farm.any:

    /siteB_farm { $include "../common_farm_parts/common_farm_base.any" /virtualhosts { "/siteb.domain.com/*" "/siteb/*" } /filters { $include "../filters/filtersB.any" } /cache { $include "../cache/siteBCache.any" } }
Santosh Sai