Problem with the AEM dispatcher rewrite rules | Community
Skip to main content
Level 2
February 28, 2025

Problem with the AEM dispatcher rewrite rules

We are trying to set the cookie userRegionDispatcher when the dispatcher domain

(https://dev-aem-www.samplerm.org/home) gets loaded but that's actually not happening.

 

Please find the below rewrite rules from the dispatcher. 

We don't see any effect with the code(last line of the code piece) we have added.

Can someone help us out on the problem.

 

################################################# ## Rules for setting up userRegion cookie at the starting ################################################# # For 'us' or 'in' country codes RewriteCond %{HTTP:x-aem-client-country} ^(us|in)$ [NC] RewriteCond %{HTTP_COOKIE} !userRegion= [NC] RewriteRule ^ - [CO=userRegion=%1:31557600:/:Secure] # For 'mena' countries RewriteCond %{HTTP:x-aem-client-country} ^(DZ|DZA|BH|BHR|KM|COM|DJ|DJI|EG|EGY|IQ|IRQ|JO|JOR|KW|KWT|LB|LBN|LY|LBY|MA|MAR|MR|MRT|OM|OMN|PS|PSE|QA|QAT|SA|SAU|SO|SOM|SD|SDN|SY|SYR|TN|TUN|AE|ARE|YE|YEM)$ [NC] RewriteCond %{HTTP_COOKIE} !userRegion= [NC] RewriteRule ^ - [CO=userRegion=mena:31557600:/:Secure] ################################################# ## Trying to set up a userRegionDispatcher ################################################# RewriteRule ^ - [CO=userRegionDispatcher=samplecookie:31557600:/]

 

 

7 replies

kautuk_sahni
Employee
March 5, 2025

@shyamsundar Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Translate
Kautuk Sahni
AMANATH_ULLAH
New Participant
February 28, 2025

@shyamsundar 

Can you try adding secure flag to the rule as below

RewriteRule ^ - [CO=userRegionDispatcher=samplecookie:31557600:/:Secure]

 

Translate
Amanath Ullah
Level 2
March 1, 2025

@amanath_ullah  - Tried this rewrite rule which did not work either 😞

 

RewriteRule ^ - [CO=userRegionDispatcher=samplecookie:31557600:/:Secure]

Translate
Rohit_Utreja
New Participant
February 28, 2025

Hi @shyamsundar ,

RewriteEngine On # Set userRegion and userRegionDispatcher together if not set RewriteCond %{HTTP:x-aem-client-country} ^(us|in)$ [NC] RewriteCond %{HTTP_COOKIE} !userRegion= [NC] RewriteRule ^ - [CO=userRegion=%1:31557600:/:Secure,CO=userRegionDispatcher=samplecookie:31557600:/] RewriteCond %{HTTP:x-aem-client-country} ^(DZ|DZA|BH|BHR|KM|COM|DJ|DJI|EG|EGY|IQ|IRQ|JO|JOR|KW|KWT|LB|LBN|LY|LBY|MA|MAR|MR|MRT|OM|OMN|PS|PSE|QA|QAT|SA|SAU|SO|SOM|SD|SDN|SY|SYR|TN|TUN|AE|ARE|YE|YEM)$ [NC] RewriteCond %{HTTP_COOKIE} !userRegion= [NC] RewriteRule ^ - [CO=userRegion=mena:31557600:/:Secure,CO=userRegionDispatcher=samplecookie:31557600:/] # Ensure userRegionDispatcher is set separately if missing RewriteCond %{HTTP_COOKIE} !userRegionDispatcher= [NC] RewriteRule ^ - [CO=userRegionDispatcher=samplecookie:31557600:/] # Ensure Dispatcher allows cookies <IfModule mod_headers.c> Header always edit Set-Cookie "(?i)^userRegionDispatcher=" "$0; SameSite=None" </IfModule>

Can you try with the below code?

Translate
Level 2
February 28, 2025

@rohit_utreja  Tried whatever dispatcher rewrite rule given. No luck bro.

Still I don't find the userRegionDispatcher cookie set in the dispatcher domain

 

 

Translate
Rohit_Utreja
New Participant
February 28, 2025

try with below

RewriteRule ^ - [CO=userRegionDispatcher=samplecookie:31557600:/:Secure;SameSite=None]
Translate