Dynamic value for redirect page property | Community
Skip to main content
Level 4
May 3, 2022 6:15 PM UTC
Solved

Dynamic value for redirect page property

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
May 4, 2022 4:08 PM UTC

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

6 replies

Himanshu_Jain
New Participant
May 4, 2022 9:06 AM UTC

Add redirects at dispatcher level .

Translate
Himanshu Jain
arunpatidar
New Participant
May 4, 2022 7:53 AM UTC

Hi,

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

Translate
Arun Patidar
nbg62Author
Level 4
May 4, 2022 3:44 PM UTC

Hi Arun,

 

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

Translate
Ravi_Pampana
New Participant
May 3, 2022 10:28 PM UTC

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/

 

Translate
nbg62Author
Level 4
May 4, 2022 9:18 AM UTC

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.

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
May 4, 2022 4:08 PM UTC

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]
 

 

Translate
Arun Patidar