Dynamic value for redirect page property | Community
Skip to main content
Level 4
May 3, 2022
Solved

Dynamic value for redirect page property

  • May 3, 2022
  • 3 replies
  • 1326 views

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.
Best answer by arunpatidar

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]
 

 

3 replies

Ravi_Pampana
Community Advisor
Community Advisor
May 3, 2022

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/

 

nbg62Author
Level 4
May 4, 2022

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.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
May 4, 2022

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
arunpatidar
Community Advisor
Community Advisor
May 4, 2022

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
nbg62Author
Level 4
May 4, 2022

Hi Arun,

 

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

Himanshu_Jain
Community Advisor
Community Advisor
May 4, 2022

Add redirects at dispatcher level .

Himanshu Jain