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?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
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:
Create a dedicated macro definition file: conf.d/available_vhosts/macros.conf or conf.d/available_vhosts/vhost_macros.conf
Place individual macro definitions in this file
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>
Views
Replies
Total Likes
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:
Create a dedicated macro definition file: conf.d/available_vhosts/macros.conf or conf.d/available_vhosts/vhost_macros.conf
Place individual macro definitions in this file
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>
Views
Replies
Total Likes
observing error during deployment
Syntax error on line 34 of /etc/httpd/conf.d/enabled_vhosts/01_brandA.vhost: no macro defined before UseBut '1_macros.conf' is already defined in available_vhosts
Views
Replies
Total Likes
Are you importing the 1_macros.conf file with the Include directive?
Views
Replies
Total Likes
imported macros using below concept
Its is working after importing in this way.
@giuseppebaglio thankyou 😁