How to redirect a Page request to another Page in a different AEM Instance ? | Community
Skip to main content
Level 2
January 12, 2024
Solved

How to redirect a Page request to another Page in a different AEM Instance ?

  • January 12, 2024
  • 2 replies
  • 2664 views

Hello, I would like to explore the Redirection options available for one of our scenario. We have Two different AEM instances for different purposes (NOT meaning a stand-by instance here).
When there is a page request to 'PAGE A' located in AEM Instance-1, we want a different page, say 'PAGE B' on AEM Instance-2 to be served.  I am aware of options like Page Redirect configurations on Page Properties, Dispatcher Url rewriting etc, Kindly suggest the most Optimal & Flexible option to achieve this redirection.

Also kindly clarify if "Page Redirection" field under the Advanced Page Properties has the capacity to redirect to other page within the Same instance only ? 

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 sarav_prakash

Fastest redirect is the one happening closest to client browser. Client-side redirects is not an option. The next closest choice would be CDN redirects. Do you have Akamai/Fastly CDN? Edge redirector is the best option. If no, next layer is Apache Http server using Dispatcher rules. You can write Proxy rewrites, so first AEM dispatcher will reverse proxy to second AEM server. 

 

I have used RewriteMap

A very good option. Basically write a servlet that returns exact .txt map file entries. Map file is stored at dispatcher. It was AEM6.5 Onprem. We had cron job running on jenkins that nightly refreshes this .txt mapfile.Every request, apache asserts against Map entry and redirects accordingly. Same can be elevated to CDN edge redirector if tool allows. 

 

Preferably avoid AEM server-side redirects like Sling redirects or the ACS Commons tool. We want to avert traffic hitting AEM server. Reduce AEM traffic and divert at higher layers. Try CDN or stick to dispatcher only. 

2 replies

Raja_Reddy
Community Advisor
Community Advisor
January 12, 2024

Hi @prasanthanandharaj 

where a request for 'PAGE A' on AEM Instance-1 should be redirected to 'PAGE B' on AEM Instance-2, you can consider the following options:

  1. Dispatcher Url Rewriting:

    • This involves configuring the Apache Dispatcher module on your web server to rewrite URLs. You can define rules in the dispatcher.any file to rewrite requests for 'PAGE A' on Instance-1 to 'PAGE B' on Instance-2.
    • This approach is efficient at the web server level and does not require modifications within AEM.
  2. AEM Vanity URLs and Redirects:

    • Set up a Vanity URL for 'PAGE A' on AEM Instance-1 that redirects to 'PAGE B' on AEM Instance-2. This can be configured in the page properties by adding a mapping in the "Vanity URLs" tab.
    • This method is more AEM-centric and allows you to manage redirects within the AEM authoring environment.
  3. Servlet and Sling Mapping:

    • Create a custom servlet or use Sling mappings to intercept requests for 'PAGE A' on Instance-1 and programmatically redirect them to 'PAGE B' on Instance-2.
    • This option provides more flexibility for custom logic but requires coding.
Level 2
January 12, 2024

Thanks for the valuable inputs. Let me explore more on the Url Rewriting.

sarav_prakash
Community Advisor
sarav_prakashCommunity AdvisorAccepted solution
Community Advisor
January 12, 2024

Fastest redirect is the one happening closest to client browser. Client-side redirects is not an option. The next closest choice would be CDN redirects. Do you have Akamai/Fastly CDN? Edge redirector is the best option. If no, next layer is Apache Http server using Dispatcher rules. You can write Proxy rewrites, so first AEM dispatcher will reverse proxy to second AEM server. 

 

I have used RewriteMap

A very good option. Basically write a servlet that returns exact .txt map file entries. Map file is stored at dispatcher. It was AEM6.5 Onprem. We had cron job running on jenkins that nightly refreshes this .txt mapfile.Every request, apache asserts against Map entry and redirects accordingly. Same can be elevated to CDN edge redirector if tool allows. 

 

Preferably avoid AEM server-side redirects like Sling redirects or the ACS Commons tool. We want to avert traffic hitting AEM server. Reduce AEM traffic and divert at higher layers. Try CDN or stick to dispatcher only. 

Level 2
January 12, 2024

Thanks for the valuable suggestions. Understand that the better solution is to redirect on the top level of the landscape.