Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Dynamic value for redirect page property

Avatar

Level 4

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]
 

 

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 4

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]
 

 

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.

Avatar

Level 4

Hi Arun,

 

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