Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Issues with etc/map redirect

Avatar

Level 5

Hello Community - I need your suggestion related to etc/map redirect. I am trying to implement the below redirect

 

PS: We don't want to make any changes in Apache.

 

DNS: www.prepaid.test.com/prepaidcards/student.html -> www.prepaid.test.com/content/test/en/account/cardenrollment.html

 

Existing setup is CDN -> Dispatcher -> Publish Instance

 

I have the following entries but the redirect is not happening. I have also verified in /system/console/jcrresolver. I wanted to implement it as a 301 redirect. Are these entries correct?

Redirect2.png

 

Also I have another question. I have kept the domain name for sling:Mapping. is that something that we need to follow the exact name of the domain/website or we can have any name? Also do I need to specify the port no. in the node name or not? Please advise.

Redirect3.png

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Are you trying for an external redirect(sling:redirect) or internal rewrite(sling:internalRedirect)? Also check AEM is reciving direct HTTPS traffic or X-Forwarded* headers, if not create the et/map configurations under HTTP node.

Refer to https://medium.com/tech-learnings/adobe-experience-manager-aem-implementing-custom-redirect-vanity-u... for more details.

Refer to https://techforum.medium.com/configure-sling-mapping-for-resource-resolution-in-adobe-experience-man... for more details on enabling etc/mapping.

Regards

Albin I

 

 

View solution in original post

15 Replies

Avatar

Employee Advisor

 You can add a rewrite rule in Apache to do a 301 redirect. Why you are not using Apache/Web server for rewrite ?

Avatar

Level 5
@Kunal_Gaba_ - I have mistakenly pressed this as a solution. We dont want to have it in Apache. The requirement is to keep it in etc/map

Avatar

Correct answer by
Community Advisor

Are you trying for an external redirect(sling:redirect) or internal rewrite(sling:internalRedirect)? Also check AEM is reciving direct HTTPS traffic or X-Forwarded* headers, if not create the et/map configurations under HTTP node.

Refer to https://medium.com/tech-learnings/adobe-experience-manager-aem-implementing-custom-redirect-vanity-u... for more details.

Refer to https://techforum.medium.com/configure-sling-mapping-for-resource-resolution-in-adobe-experience-man... for more details on enabling etc/mapping.

Regards

Albin I

 

 

Avatar

Level 5
@Albin_Issac - Thanks for your inputs. I tried with sling:internalRedirect. Can you tell me how to check HTTPS traffic or X-Firwarded header? Also what property should I use it for the headers?

Avatar

Community Advisor
Try adding the maapings under http node, if that works. The X-Forwarded headers will be sent by Load Balancers if the SSL is terminated at Load Balancer.

Avatar

Level 5
@Albin_Issac - I have added the mapping under http node as well but the redirect is not happening. Currently I have two modes under map - http & https

Avatar

Level 5
@Albin_Issac - Please find below. { "jcr:primaryType": "sling:Folder", "jcr:createdBy": "admin", "hidden": "true", "jcr:created": "Fri Feb 07 2020 05:31:05 GMT-0600", "http": { "jcr:primaryType": "sling:Folder", "jcr:mixinTypes": [ "cq:ReplicationStatus" ], "jcr:createdBy": "admin", "cq:lastReplicationAction": "Activate", "cq:lastReplicatedBy": "admin", "jcr:created": "Fri Feb 07 2020 05:31:05 GMT-0600", "cq:lastReplicated": "Tue Jan 05 2021 14:06:49 GMT-0600", "prepaid.test.com": { "jcr:primaryType": "sling:Mapping", "jcr:mixinTypes": [ "cq:ReplicationStatus" ], "jcr:createdBy": "admin", "cq:lastReplicationAction": "Activate", "cq:lastReplicatedBy": "admin", "jcr:created": "Tue Jan 05 2021 10:16:23 GMT-0600", "cq:lastReplicated": "Tue Jan 05 2021 12:27:23 GMT-0600", "test-redirect": { "jcr:primaryType": "sling:Mapping", "jcr:mixinTypes": [ "cq:ReplicationStatus" ], "jcr:createdBy": "admin", "cq:lastReplicationAction": "Activate", "cq:lastReplicatedBy": "admin", "sling:status": 301, "jcr:created": "Tue Jan 05 2021 10:16:23 GMT-0600", "cq:lastReplicated": "Wed Jan 06 2021 11:24:33 GMT-0600", "sling:match": "/prepaidcards/student.html", "sling:internalRedirect": "/content/test/en/account/enrollment.html" } } }, "https": { "jcr:primaryType": "sling:Folder", "jcr:mixinTypes": [ "cq:ReplicationStatus" ], "jcr:createdBy": "admin", "cq:lastReplicationAction": "Activate", "cq:lastReplicatedBy": "admin", "jcr:created": "Fri Feb 07 2020 05:31:05 GMT-0600", "cq:lastReplicated": "Tue Jan 05 2021 12:27:20 GMT-0600", "prepaid.test.com": { "jcr:primaryType": "sling:Mapping", "jcr:mixinTypes": [ "cq:ReplicationStatus" ], "jcr:createdBy": "admin", "cq:lastReplicationAction": "Activate", "cq:lastReplicatedBy": "admin", "jcr:created": "Tue Jan 05 2021 10:16:23 GMT-0600", "cq:lastReplicated": "Tue Jan 05 2021 12:27:30 GMT-0600", "test-redirect": { "jcr:primaryType": "sling:Mapping", "jcr:mixinTypes": [ "cq:ReplicationStatus" ], "jcr:createdBy": "admin", "cq:lastReplicationAction": "Activate", "cq:lastReplicatedBy": "admin", "sling:status": 301, "jcr:created": "Tue Jan 05 2021 10:16:23 GMT-0600", "cq:lastReplicated": "Tue Jan 05 2021 13:37:39 GMT-0600", "sling:match": "/prepaidcards/student.html", "sling:internalRedirect": "/content/test/en/account/enrollment.html" } } } }

Avatar

Community Advisor

Try to modify the sling:match as sling:match - prepaidcards/student.html (removed the slash). Also, note sling:redirect instead of sling:internalRedirect with complete URL should used if you want to redirect the user to specific URL in browser.

Avatar

Level 5
Thanks so much for your inputs. I have changed the entries like below in the publish instances. sling:match - prepaidcards/student.html, sling:redirect - /content/test/en/account/enrollment.html The Resource Resolver output is below. Configuration Test: https://prepaid.test.com/prepaidcards/student.html RedirectResource, type=sling:redirect, path=/prepaidcards/student.html, values={sling:target=/content/test/en/account/enrollment.html, sling:status=301} The redirect is still not working. Is there a reason, I need to specify sling:redirect instead of sling:internalRedirect? We are still pointing to the page which is also in the same domain.t

Avatar

Level 5
If I check the "Resolver Map" Entries, it shows the below : Pattern: ^https/prepaid.test.com/prepaidcards.com.443/prepaidcards/student.html Replacement: /content/test/en/account/enrollment.html

Avatar

Community Advisor

Working JSON

 

{
"jcr:primaryType": "sling:Folder",
"jcr:createdBy": "admin",
"hidden": "true",
"jcr:created": "Wed Oct 16 2019 20:55:35 GMT-0500",
"http": {
"jcr:primaryType": "sling:Folder",
"jcr:createdBy": "admin",
"jcr:created": "Wed Oct 16 2019 20:55:35 GMT-0500",
"prepaid.test.com": {
"jcr:primaryType": "sling:Mapping",
"jcr:createdBy": "admin",
"jcr:created": "Wed Jan 06 2021 12:45:10 GMT-0600",
"test-redirect": {
"jcr:primaryType": "sling:Mapping",
"jcr:createdBy": "admin",
"sling:redirect": "https://www.albinsblog.com",
"jcr:created": "Wed Jan 06 2021 12:46:07 GMT-0600",
"sling:match": "prepaidcards/student.html"
}
}
}
}

Avatar

Level 5
Not sure if I have anything that is incorrect in the setup.

Avatar

Level 5
@Albin_Issac - Thank you so much for your wonderful inputs. After adding the content/test/en in the sling:match, the redirect started working. Can you please provide your inputs for the below? 1. Currently I don't have any page specific rewrite rules in apache level. Even after I delete the folders underneath the etc/map/ in all publish instances and verified, I still some of the redirects are still working. I have even cleared CDN and Dispatcher cache as well and no etc/map in the publish instances. is there any way to check from where it is actually picking it up? 2. Also while creating the sling:mapping node with the domain nam (under http), do we need to create the node name with "www" in the prefix ? if so, the domain which is not configured without "www" requires another mapping without "wwww" in the sling:mapping folder? Please advise.

Avatar

Community Advisor

Hi @v1101,

 

1. In your sling:internalRedirect, I think you have missed the "/". Please add it and try again.

2. In general, we add the sling:Mapping node in sling:Folder node which holds the domain name.

 

Hope this helps.

 

Thanks,

Kiran Vedantam.