Apache Rewrite rules for hiding servlet paths
Hi Team, @estebanbustamante @raja_reddy ,
I want to hide my servlet paths so that I need to write rewrites at dispatcher.
Currently client is calling the api in below format
Path Based: http://localhost:4502/bin/test/v1/content?type=page
Resource based: http://localhost:4502/content/test/servlets/fruits.banana.json?type=58&color=yellow
here fruits is a servlet resource node and sling:resourceType is fruits/test/servlets.
I have registered servlet resource type as fruits/test/servlets and with selectors banana and extension as json. Like this I have many servlets with same resource type and multiple selectors.
I want to mask actual servlet URLs so that,
now the client will call API in below format.
Path Based: http://localhost:4502/api/v1/content?type=page
The above URL should internally call original servlet i.e. http://localhost:4502/bin/test/v1/content?type=page
Resource based: http://localhost:4502/mask.banana.json?type=58&color=yellow
The above URL should internally call original servlet i.e. http://localhost:4502/content/test/servlets/fruits.banana.json?type=58&color=yellow
I am writing rewrites in mod_rewrite module as below.
Path based: RewriteRule ^/api/v1/(.*)$ /bin/test/v1/$1?type=page [QSA,PT,L]
Resource based: RewriteRule ^/mask.(.*)$ http://localhost:4502/content/test/servlets/fruits.$1?type=58&color=yellow [QSA,PT,L]
Using QSA flag to pass the query params from proxy servlet to actual.
The above rules not giving expected result. Please suggest how can I achieve this
Thanks!

