Search code examples
springtomcatspring-mvcurl-rewritingtuckey-urlrewrite-filter

Using tuckey, remove all query string paramerers from the url when a particular parameter exists


I just got introduced to tuckey and was playing around with rewriting url query parameters in a pentaho server (spring).

What I am trying to do: Rewrite

http://hostname:8080/pentaho/api/repos/:public:Steel%20Wheels:Regional%20Sales%20%28dashboard%29.xdash/viewer?token=ABC-1234-42rheRFrhewu2425-ticket&username=popcorn

TO

http://hostname:8080/pentaho/api/repos/:public:Steel%20Wheels:Regional%20Sales%20%28dashboard%29.xdash/viewer

Things that didn't work for me:

<rule>
    <from>^/viewer$</from>
    <to type="redirect" last="true">/viewer</to>
</rule>

<rule>
    <condition type="parameter" name="token" operator="equal">(*)</condition>
    <from>^/viewer$</from>
    <to type="permanent-redirect" last="true">viewer</to>
</rule>

and many variants. checked old posts also. I know I could be either doing something wrong with regex or the configuration is completely off. any pointers are appreciated.


Solution

  • Forgot completely about this questions since no one responded. Answering myself in case some one finds themselves in same position.

    <rule>
        <condition type="parameter" name="token" operator="equal">(*)</condition>
        <from>^/viewer(.*)$</from>
        <to type="permanent-redirect" last="true">viewer</to>
    </rule>