Expand my Community achievements bar.

SOLVED

Dynamic value for redirect page property

Avatar

Level 5

We're builfing multi country/language sites. On one of the page templates, under initial page properties / Advanced, we set Redirect property to us/english site, for example, /content/site/us/en/homepage.

When creating page for another country / language using that template we would like redirect property to be dynamically  changed to context of that country/lang, for example, /content/site/be/fr/homepage.

 

Thank you

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Example rules :

RewriteRule ^/content/site/us/en.html$ /content/site/us/en/homepage.html [PT,NE,L]
RewriteRule ^/content/site/be/fr.html$ /content/site/be/fr/homepage.html [PT,NE,L]
 

 



Arun Patidar

View solution in original post

6 Replies

Avatar

Community Advisor

Hi,

We can achieve this using event listener when jcr:content node is created/updated event can be triggered 

 

Ex: https://aemhints.com/2020/11/08/event-listener-in-aem-6-5/

 

Avatar

Level 5

Thank you,

 

I was thinking about that but I'm not sure if my use case applies to rewrite on dispatcher level.

 

For example, if on the dispatcher I got request to redirect to default redirect path which is set on the template level "/content/site/us/en/homepage"

1. Dispatcher gets url "/content/site/us/en/homepage"

2. On the dispatcher I need to determine what's my current country/lang site, for example "/be/fr/", is that possible  ?

3. I need to extract "be/fr" from current context.

4. Replace, "us/en" with "be/fr"

 

I'm not sure If got this correct.

Avatar

Correct answer by
Community Advisor

Example rules :

RewriteRule ^/content/site/us/en.html$ /content/site/us/en/homepage.html [PT,NE,L]
RewriteRule ^/content/site/be/fr.html$ /content/site/be/fr/homepage.html [PT,NE,L]
 

 



Arun Patidar

Avatar

Community Advisor

Hi,

set this redirect at apache/dispatcher level, no need to process a page for just redirect and make a load on publish instance.



Arun Patidar

Avatar

Level 5

Hi Arun,

 

can you check my answer above (wrongly posted to different thread)

Avatar

Community Advisor

Add redirects at dispatcher level .

Himanshu Jain