Expand my Community achievements bar.

SOLVED

Dispatcher rewrite rule for redirection to a sling servlet

Avatar

Adobe Champion

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 

1 Accepted Solution

Avatar

Correct answer by
Adobe Champion

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 

 

 

View solution in original post

5 Replies

Avatar

Community Advisor

Hi,

If you have servlet in /apps then you need to allow anonymous user for accessing the this servlet.

 

Although the redirect rule is

 

 

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

 

https://technicalseo.com/tools/htaccess/?share=ewogICJ1cmwiOiAiaHR0cDovL3Rlc3QudGVzdC5jYS9yZWFkZXI/a... 



Arun Patidar

Avatar

Adobe Champion

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?

Avatar

Community Advisor

Hi,

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



Arun Patidar

Avatar

Correct answer by
Adobe Champion

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