Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Reverse Resource Resolver Mapping

Sady_Rifat
Level 2
Level 2

Hi,

I have a content path /content/my-project/gb/en/home/test.

Then I used request.getResourceResolver().map("/content/my-project/gb/en/home/test").

Output: https://www.myproject.com/en/home/test.html 

 

Now I want to reverse this process. I need the actual content path from the mapped path.

Ex: https://www.myproject.com/en/home/test.html to /content/my-project/gb/en/home/test

Any idea how I can achieve this? [I tried resourceResolver.resolve("https://www.myproject.com/en/home/test.html").getPath() but it's not working.]

Thanks in advance.

1 Accepted Solution
Bimmi_Soi
Correct answer by
Employee
Employee

Hi @Sady_Rifat ,

 

You can do it using two ways:

  • Etc map : As suggested by @bangar50 .
  • Rewrite rule : You can add a rewrite rule as below

RewriteRule ^/(.*)$ /content/my-project/gb/$1.html [PT,L]

 

Hope this helps!!

 

Thanks

View solution in original post

2 Replies
bangar50
Level 7
Level 7

Hi @Sady_Rifat ,

         Can you please try  using etc/mapping and create new node in /etc/map with below value for reverse mapping.

sling:internalRedirect  String /content/site/en/en/(.*).html  sling:match String localhost.4502/en/$1

reverse mapping like above and to map short urls to actual content you can create mapping.

 

 

Regards,

Sanjay

Bimmi_Soi
Correct answer by
Employee
Employee

Hi @Sady_Rifat ,

 

You can do it using two ways:

  • Etc map : As suggested by @bangar50 .
  • Rewrite rule : You can add a rewrite rule as below

RewriteRule ^/(.*)$ /content/my-project/gb/$1.html [PT,L]

 

Hope this helps!!

 

Thanks

View solution in original post