AEMaaCS how to use Macro in dispatcher | Community
Skip to main content
Level 2
November 11, 2025
Solved

AEMaaCS how to use Macro in dispatcher

Please guide on how to use Macro in AEMaaCS  dispatcher.

In which folder we should declare Macro and how to call it in Vhost ?

 

We are using Multi-site setup, need multiple vhost files and how to make it generic and use Macro 

https://httpd.apache.org/docs/2.4/mod/mod_macro.html#use

Checked above document, but not sure how to make a complete vhost as a Macro and how to call it in enabled vhosts folder?

 

Can we call a Macro within a Macro?

Can we create full  vhost using Macro instead of creating Macro just to include Rewrite rules?

giuseppebaglio
giuseppebaglioAccepted solution
Level 10
November 11, 2025

Apache mod_macro is fully supported in AEMasCS Dispatcher, and here you can find a good guide to walk you through: https://www.aemguide.in/?m=0 

You can declare macros in the conf.d/available_vhosts folder structure. For example:​

  1. Create a dedicated macro definition file: conf.d/available_vhosts/macros.conf or conf.d/available_vhosts/vhost_macros.conf

  2. Place individual macro definitions in this file

  3. Include this macro file at the top of your vhost configuration files

Structure of your dispatcher configuration:

dispatcher/ ├── conf.d/ │ ├── available_vhosts/ │ │ ├── macros.conf (macro definitions) │ │ └── site_template.vhost (optional template) │ └── enabled_vhosts/ │ ├── site1.vhost (uses macro) │ ├── site2.vhost (uses macro) │ └── site3.vhost (uses macro) ├── conf.dispatcher.d/ │ ├── available_farms/ │ └── enabled_farms/ │ ├── site1_farm.any │ ├── site2_farm.any │ └── site3_farm.any

 

I never tried before, but you should be able to call nested macros:

<Macro CommonRewriteRules $sitename> RewriteEngine On RewriteCond %{REQUEST_URI} !^/dispatcher/invalidate.cache RewriteRule ^/$ /content/$sitename/home.html [PT,L] </Macro> <Macro FullVHost $sitename $domain $docroot> <VirtualHost *:80> ServerName $domain DocumentRoot $docroot <Directory $docroot> <IfModule disp_apache2.c> SetHandler dispatcher-handler </IfModule> </Directory> # Call nested macro Use CommonRewriteRules $sitename ErrorLog logs/$sitename-error.log </VirtualHost> </Macro>

 

 

4 replies

giuseppebaglio
giuseppebaglioAccepted solution
Level 10
November 11, 2025

Apache mod_macro is fully supported in AEMasCS Dispatcher, and here you can find a good guide to walk you through: https://www.aemguide.in/?m=0 

You can declare macros in the conf.d/available_vhosts folder structure. For example:​

  1. Create a dedicated macro definition file: conf.d/available_vhosts/macros.conf or conf.d/available_vhosts/vhost_macros.conf

  2. Place individual macro definitions in this file

  3. Include this macro file at the top of your vhost configuration files

Structure of your dispatcher configuration:

dispatcher/ ├── conf.d/ │ ├── available_vhosts/ │ │ ├── macros.conf (macro definitions) │ │ └── site_template.vhost (optional template) │ └── enabled_vhosts/ │ ├── site1.vhost (uses macro) │ ├── site2.vhost (uses macro) │ └── site3.vhost (uses macro) ├── conf.dispatcher.d/ │ ├── available_farms/ │ └── enabled_farms/ │ ├── site1_farm.any │ ├── site2_farm.any │ └── site3_farm.any

 

I never tried before, but you should be able to call nested macros:

<Macro CommonRewriteRules $sitename> RewriteEngine On RewriteCond %{REQUEST_URI} !^/dispatcher/invalidate.cache RewriteRule ^/$ /content/$sitename/home.html [PT,L] </Macro> <Macro FullVHost $sitename $domain $docroot> <VirtualHost *:80> ServerName $domain DocumentRoot $docroot <Directory $docroot> <IfModule disp_apache2.c> SetHandler dispatcher-handler </IfModule> </Directory> # Call nested macro Use CommonRewriteRules $sitename ErrorLog logs/$sitename-error.log </VirtualHost> </Macro>

 

 
Translate
VishnuRa5Author
Level 2
November 11, 2025

@giuseppebaglio 

observing error during deployment 

Syntax error on line 34 of /etc/httpd/conf.d/enabled_vhosts/01_brandA.vhost: no macro defined before Use

But '1_macros.conf' is already defined  in available_vhosts 

Translate
giuseppebaglio
Level 10
November 11, 2025

Are you importing the 1_macros.conf file with the Include directive?

 

Translate