Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Opening a page in author even after the page has redirect url

Avatar

Level 3

Hi all,

In AEM author, I have opened a page (say URL1). I have set the Redirect path(in Advanced Tab) to URL2. So, Now if I open the page URL1 in author, publish environment, it will redirect to URL2. But author wants to open the URL1 page. Since he has to author URL1 page. Is this possible to open URL1 page?  At the end what I am asking is : Redirect should happen only in publish environment, not in author environment.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @gmahesh 

 

A condition to redirect only if wcmmode mode is disabled can be added in redirect.html. If you are using core components then you can overlay /apps/core/wcm/components/page/v2/page/page.html and add a condition similar to the below code.

<sly data-sly-test.isRedirectPage="${page.redirectTarget && (wcmmode.edit || wcmmode.preview)}"
data-sly-call="${redirect.redirect @ redirectTarget = page.redirectTarget}"></sly>
<sly data-sly-test="${!isRedirectPage}">
<sly data-sly-include="body.skiptomaincontent.html"></sly>
<sly data-sly-include="body.socialmedia_begin.html"></sly>
<sly data-sly-include="body.html"></sly>
<sly data-sly-call="${footer.footer @ page = page, pwa = pwa}"></sly>
<sly data-sly-include="body.socialmedia_end.html"></sly>
</sly> 

 

Refer this community answer for more info. https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/page-with-a-redirect-page-... 

Thanks

View solution in original post

7 Replies

Avatar

Employee Advisor

hi @gmahesh,
You can easily achieve by overlaying the page component from here(/apps/core/wcm/components/page/v2/page/page.html) and adding a condition to check and make redirection or open page based on wcmmode.diabled or wcmmode.edit/wcmmode.preview

There is a same question and you can refer here: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/page-with-a-redirect-page-...

 

Avatar

Correct answer by
Community Advisor

Hi @gmahesh 

 

A condition to redirect only if wcmmode mode is disabled can be added in redirect.html. If you are using core components then you can overlay /apps/core/wcm/components/page/v2/page/page.html and add a condition similar to the below code.

<sly data-sly-test.isRedirectPage="${page.redirectTarget && (wcmmode.edit || wcmmode.preview)}"
data-sly-call="${redirect.redirect @ redirectTarget = page.redirectTarget}"></sly>
<sly data-sly-test="${!isRedirectPage}">
<sly data-sly-include="body.skiptomaincontent.html"></sly>
<sly data-sly-include="body.socialmedia_begin.html"></sly>
<sly data-sly-include="body.html"></sly>
<sly data-sly-call="${footer.footer @ page = page, pwa = pwa}"></sly>
<sly data-sly-include="body.socialmedia_end.html"></sly>
</sly> 

 

Refer this community answer for more info. https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/page-with-a-redirect-page-... 

Thanks

Avatar

Level 3

Hey dev_aem,

I have 1 more query. Is it possible to change the behavior for  foundational page. (I mean my page has : sling:resourceSuperType wcm/foundation/components/page)

Avatar

Community Advisor

Yes it's possible. You can overlay /libs/wcm/foundation/components/page/redirect.html into your page component and add your required logic in the overlayed file.

Avatar

Level 2

your question is unclear. "if I open the page URL1 in author, publish environment," - what does this mean?

 

from my experience redirected pages open fine in author (edit mode, not view as publish mode) and redirect in publish, which is what you would expect.

 

view as publish would behave as publish and would redirect, which is again as expected.