You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@knox.apache.org by Priyanka Gupta <Pr...@guavus.com> on 2018/08/16 07:40:28 UTC

Need help on rewrite rules

Hi,

I need some help on a rewrite rule.I have a java script which is internally calling other java scripts.So I tried to modify the url of those javascript using filters.

Java scripts url : </cdap_assets/img/cdap_logo.png>


But these requests are not changing.


    <rule dir="OUT" name="CDAPUI/cdapui/outbound/imgs" pattern="img/{**}">
        <rewrite template="{$frontend[path]}/cdapui/cdap_assets/img/{**}"/>
    </rule>

    <rule dir="OUT" name="CDAPUI/cdapui/outbound/img">
        <rewrite template="cdapui/cdap_assets/img/cdap_logo.png"/>
    </rule>

    <filter name="CDAPUI/cdapui/outbound/app">
    <content type="application/javascript">
        <apply path="/cdap_assets/img/cdap_logo.png" rule="CDAPUI/cdapui/outbound/img"/>
    </content>
    </filter>


Also, I tied the rule to service.xml like:

    <routes>
        <route path="/cdapui/**">
            <rewrite apply="CDAPUI/cdapui/outbound/app" to="response.body"/>
        </route>
    </routes>


Thanks in advance!










Re: Need help on rewrite rules

Posted by Sandeep Moré <mo...@gmail.com>.
Hello Priyanka,

Sometimes the content types do not match, can you check if the response
type you are getting back is indeed "application/javascript" ?
Also, try using a broader rule on service.xml for testing something like /
Do you see any failures in gateway.log, i.e. failure to apply rules etc.

On Thu, Aug 16, 2018 at 3:40 AM Priyanka Gupta <Pr...@guavus.com>
wrote:

> Hi,
>
> I need some help on a rewrite rule.I have a java script which is internally calling other java scripts.So I tried to modify the url of those javascript using filters.
>
> Java scripts url : </cdap_assets/img/cdap_logo.png>
>
>
> But these requests are not changing.
>
>
>     <rule dir="OUT" name="CDAPUI/cdapui/outbound/imgs" pattern="img/{**}">
>         <rewrite template="{$frontend[path]}/cdapui/cdap_assets/img/{**}"/>
>     </rule>
>
>     <rule dir="OUT" name="CDAPUI/cdapui/outbound/img">
>         <rewrite template="cdapui/cdap_assets/img/cdap_logo.png"/>
>     </rule>
>
>     <filter name="CDAPUI/cdapui/outbound/app">
>     <content type="application/javascript">
>         <apply path="/cdap_assets/img/cdap_logo.png" rule="CDAPUI/cdapui/outbound/img"/>
>     </content>
>     </filter>
>
>
> Also, I tied the rule to service.xml like:
>
>     <routes>
>         <route path="/cdapui/**">
>             <rewrite apply="CDAPUI/cdapui/outbound/app" to="response.body"/>
>         </route>
>     </routes>
>
>
> Thanks in advance!
>
>
>
>
>
>
>
>