AEM Dispatcher - Multiple Redirect Rules File in VHosts
Hi AEM Community,
I have the below use case -
1. VHost File with redirect engine on and 2 rewrites inclusion
<IfModule mod_rewrite.c>
RewriteEngine On
Include conf.d/rewrites/rewrite.rules
Include conf.d/rewrites/rewrites_brandA.rules
</IfModule>
The rewrites in rewrite.rules are executed but not the one in rewrites_brandA.rules
2. VHost File with 1 include and 1 rewrite instruction
<IfModule mod_rewrite.c>
RewriteEngine On
Include conf.d/rewrites/rewrite.rules
RewriteRule "^(/?)$" "/content/brandA/us/en/home.html" [PT,L]
</IfModule>
The rewrite rule written later is also not executed by Dispatcher.
3. VHost File with rewrite.rules inclusion, and rewrite.rules can have any number of rules or further files inclusion.
<IfModule mod_rewrite.c>
RewriteEngine On
Include conf.d/rewrites/rewrite.rules
</IfModule>
Rewrite.rules File -
Include conf.d/rewrites/default_rewrite.rules
Include conf.d/rewrites/brandA_rewrite.rules
Why am I unable to write rules directly in vhost file or call custom rules file directly from vhost ?
As we will have a multi tenancy architecture, how do we map each rules file to custom domain from rewrite.rules file ?
I tried the below but had issues as my rewrite file had <LocationMatch> is not allowed inside <If> context
<If "%{HTTP_HOST} == 'brandA.com'">
Include conf.d/rewrites/brandA_rewrite.rules
</If>
<If "%{HTTP_HOST} == 'publish.com'">
Include conf.d/rewrites/default_rewrite.rules
</If>
Can you please help with the best way to handle this ?
@arunpatidar , @albinis1 , @Jörg_Hoh @b_sravan
Thanks in advance,
Rohan Garg
