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.
Solved! Go to Solution.
Views
Replies
Total Likes
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
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-...
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
Thanks a lot dev_aem. Your answer is perfect one.
Glad it helped
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)
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.
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.