Highlighted

AEM - Set External Page Redirect that carries Query Parameters

vinceg62980830

16-04-2018

Hi everyone,

Not sure if anyone else had come across this similar situation...

We want to leverage the "Page Redirect" placeholder page, or even the Redirect field in a page's Page Properties, to setup a "single/global redirect" to a sister website. However, we need to be able to pass-thru query parameters during that redirect.

So for example:

AEM == https://www.mysite.com/

Sister site == https://www.sistersite.com/

We'd like to have URLs that point to the sister site, and rather than always manually inputting their URL we'd like to setup an AEM webpage that redirects, so:

AEM page == https://www.mysite.com/content/gotosister --> https://www.sistersite.com/

The kicker is, current redirects using either the "Page Redirect" placeholder page or the Page Properties redirect strips out any Query Params that may be on it. Is there a way for it to retain/pass-thru query params? So:

https://www.mysite.com/content/gotosister?param=foo --> https://www.sistersite.com/?param=foo

Replies

Highlighted

edubey

16-04-2018

You properly would have to overlay this file  /libs/foundation/components/page/redirect.jsp or /libs/wcm/foundation/components/page/redirect.html and correct logic for your use case. Doesn't seems to be much of work.

Highlighted

vinceg62980830

19-04-2018

Thanks for responding, @edubey.

I see that the HTL is already appending .html to the path:

<p data-sly-test="${properties.redirectTarget}" class="cq-redirect-notice">

    This page redirects to <a href="${properties.redirectTarget}.html">here</a>

</p>

how would we pass params after that appended .html portion?