コミュニティアチーブメントバーを展開する。

Problem with the AEM dispatcher rewrite rules

Avatar

Level 2

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 返信

Avatar

Community Advisor

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?

Avatar

Level 2

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

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

 

ShyamSundar_0-1740750786817.png

 

Avatar

Community Advisor

try with below

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

Avatar

Level 2

Still the same problem bro.

Avatar

Community Advisor

@ShyamSundar 

Can you try adding secure flag to the rule as below

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

 


Amanath Ullah

Avatar

Level 2

@AMANATH_ULLAH  - Tried this rewrite rule which did not work either

 

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

Avatar

Administrator

@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!



Kautuk Sahni