Expand my Community achievements bar.

URL rewriting in AEM cloud using etc/maps and resource resolver mappings

Avatar

Level 2
Hi AEM community,
 
I'm currently working on implementing URL rewriting as mentioned below:
 
From: `/content/test/en/gyms/services/personal-training/location`
To: `/gyms/location/services/personal-training`
 
The goal is to have the public-facing URL as `/gyms/location/services/personal-training`, which will correspond to the internal URL of `/content/test/en/gyms/services/personal-training/location.html`.
 
I've configured the etc/map mapping and resource resolver config entries accordingly (please see the attached screenshots).
While this setup works flawlessly in the local publisher environment, it's encountering issues when deployed to AEM cloud publish environments. Additionally, we have a link transformer configuration in place to transform the href of these pages which is also not working (maybe because rewrites are not happening) (as shown in the attached screenshot).
 
Can anyone please help on how to make it work in AEM cloud publish environments ?
Also, what is the correct place to add etc/mappings - under ui.apps or ui.content in the repo ?
 
 
Screenshot 2024-04-16 at 22.22.04.pngScreenshot 2024-04-16 at 22.22.25.png
14 Replies

Avatar

Community Advisor

@SaumyaJa 

 

We have created sling mappings in following location

aanchalsikka_0-1713333536691.png

 

Sling Mappings are capable to altering URLs in pages. 

 

Please refer to https://youtu.be/bJ_cXcAE7G8?t=1080  It explains both forward and reverse


Aanchal Sikka

Avatar

Level 2

I tried this as well but for me it is still not working. 

 

Screenshot 2024-04-17 at 09.32.27.png

Avatar

Level 2

Can you help me with what should be the value of "resource.resolver.map.location" property in this config org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.cfg.json ?

 

should it be /conf path or /etc path ?

 

Avatar

Level 2

Hi @SaumyaJa 

To already answer your question about where to store it, it should be below ui.apps.

Can you send me the path where you added the Resource Resolver Configuration in your project?

Greetings

Rik

Avatar

Level 2

It is under ui.config/src/main/content/jcr_root/apps/<project-folder>/osgiconfig/config.publish/org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.cfg.json

Avatar

Level 2

And do you hvae one configured for a specific environment in ui.config/src/main/content/jcr_root/apps/<project-folder>/osgiconfig/config.[environment].publish?

 

Because that would overwrite the more generic one.

Also to verify if your configuration is deployed correctly you can go to the developer console and print all the OSGi Configurations from the publishers and search for your configurations.


Here you have a step-to-step guide on how to get OSGi Configurations through the developer console.

Avatar

Level 2

No, as of now we have the general one like config.publish. And i verified in Dev publish developer console - the configuration exists with these mappings.

Avatar

Level 2

I think we'll need some extra debugging to verify what the issue is.
Can you go to the this link, here you can test your sling mappings.

 

1. Make sure that the right sling mapping is applied here.

2. Here you can fill in the request you would do on your cloud environment

3. Click on resolve to check if it points to the correct internal url

RikVanB_1-1713427940254.png

 

Avatar

Level 2

Unfortunately, we dont have access to this link in Dev publish instance. In local , i have checked multiple times and it is working perfectly.

The issue is with Dev publish cloud environment.

Avatar

Level 2

Thanks for the reply, could you check the logs of the dispatcher to verify if the requests to /gyms/services/personal-training/location.html are blocked or not?

You can also check the access logs of the publisher to see if the request is comming through or not.

Let me know what you see in the logs.

 

Greetings

Rik

Avatar

Community Advisor

@SaumyaJa Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Esteban Bustamante

Avatar

Level 1

Hi, Please can you tell how to mark correct a answer?? For that we have to post a question or we can mark correct previous answers also given on any other questions??

And how to do that??

Avatar

Level 2

Not yet. None of the above answers is working for cloud publish environment. Hence still debugging.

Have raised an adobe support ticket as well. Will update as soon as i get the solution.