Dispatcher rewrite rule for redirection to a sling servlet | Community
Skip to main content
New Participant
May 27, 2022 1:25 PM UTC
Solved

Dispatcher rewrite rule for redirection to a sling servlet

Can someone help me with the rewrite rule for the below scenario?

 

If I hit http://test.test.ca/reader?id=0f69571b-a2ce-4c04-8df8-dc46b137f677 should redirect to this url http://test.test.ca/apps/sling/servlet/asset/test-reader?id=0f69571b-a2ce-4c04-8df8-dc46b137f677, Here id is dynamic and will be different each request and apps/sling/servlet/asset/test-reader is where the resourcetype node reside for my servlet.

 

@arunpatidar 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
P_V_NairAccepted solution
New Participant
May 27, 2022 3:42 PM UTC

Hi,

Its not needed, you can test the rule in the link which I have shared or in local dispatcher setup


I had to add a slash to the above rule you gave as below

 

RewriteRule "^/reader""/apps/sling/servlet/asset/test-reader"[PT]

 

and that worked. Thanks a lit @arunpatidar 

 

 

5 replies

arunpatidar
New Participant
May 27, 2022 1:35 PM UTC
P_V_NairAuthor
New Participant
May 27, 2022 2:05 PM UTC

Thanks @arunpatidar . The anonymous read only access to that node is already in place and so we are good with that perspective. 

But I have a doubt in the rewrite rule. So, shouldn't add anything related to id in the rewrite rule?

Translate
arunpatidar
New Participant
May 27, 2022 3:03 PM UTC

Hi,

Its not needed, you can test the rule in the link which I have shared or in local dispatcher setup

Translate
Arun Patidar