React redirection | Community
Skip to main content
Level 2
July 5, 2024

React redirection

  • July 5, 2024
  • 1 reply
  • 482 views

We have a requirement  in our AEM SPA website to internally redirect to new page when user hit the old page hierarchy. So the old pages are not present in AEM physically. There is also a requirement that URL on browser should not change. So we used PT in rewrite rule.

For example http://domain/content/mysite/in/en/oldpage/scheme.html  should be redirected to http://domain/content/mysite/in/en/newpage.html 

Here is our redirect rule:

RewriteCond %{REQUEST_URI} ^/content/${CONTENT_FOLDER_NAME}/in/en/oldpage/(.*?)\.html$ [NC]
RewriteRule ^/content/${CONTENT_FOLDER_NAME}/in/en/oldpage/(.*?)\.html$ /content/${CONTENT_FOLDER_NAME}/in/en/newpage.html [PT,L]

RewriteCond %{REQUEST_URI} ^/content/${CONTENT_FOLDER_NAME}/in/en/oldpage/(.*?)\.model.json$ [NC]
RewriteRule ^/content/${CONTENT_FOLDER_NAME}/in/en/oldpage/(.*?)\.model.json$ /content/${CONTENT_FOLDER_NAME}/in/en/newpage.model.json [PT,L]

Here redirection is working as expected. Page is getting redirected to newpage.html but content is not getting displayed. We see a blank page.

When we set isRoot as false in page policy, redirection is working fine. But on click of any links, only URL get change, and not that page content. When we refresh page, content is getting rendered.

 

@shashi_mulugu @nikhil-kumar @raja_reddy @kautuk_sahni 

 

 

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

MukeshYadav_
Community Advisor
Community Advisor
July 6, 2024

Hi @iamaemuser ,

 

Kindly share / check the dispatcher logs and network tab whether any response is getting blocked / status code.

Check and update allow and deny paths in your dispatcher configuration accordingly.

Also hopefully you may be checking by removing cache or rerun apache

 

Thanks,