# URI Rewrite without Redirection

**URL:** <https://community.f5.com/t/uri-rewrite-without-redirection/18938>\
**Category:** Technical Forums\
**Tags:** design, management, big-ip-access-policy-manager-apm, irules, devops, security, ltm, application-delivery\
**Created:** [June 25, 2015, 10:51pm UTC](https://community.f5.com/t/uri-rewrite-without-redirection/18938 "2015-06-25T22:51:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_The\_203](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@Richard\_The\_203](https://community.f5.com/u/Richard_The_203)\
**Post date:** [June 25, 2015, 10:51pm UTC](https://community.f5.com/t/uri-rewrite-without-redirection/18938/1 "2015-06-25T22:51:29Z")

</div>

Hi,

I have an NGINX rule that needs to be translated to the equivalent iRules:

**rewrite /api/user.getInfo.(.\*) /api/user/getInfo.$1 last;**

And this is the iRules I came up with:

```tcl
"/api/user.getInfo.*" 
{
  scan [HTTP::uri] {/api/user.getInfo.%[^.]+} cap1
  HTTP::uri /api/user/getInfo.$cap1
}

```

It does the URI transformation correctly; however, I get **HTTP/1.1 302 Found** back from it. Is there a way to perform a URI rewrite without returning 301/302 (redirection) status code on F5?

Thank you!

---

<div class="post-metadata">

**Author:** ![giltjr](https://avatars.discourse-cdn.com/v4/letter/g/c4cdca/32.png) [@giltjr](https://community.f5.com/u/giltjr)\
**Post date:** [June 26, 2015, 9:37am UTC](https://community.f5.com/t/uri-rewrite-without-redirection/18938/2 "2015-06-26T09:37:44Z")

</div>

Is the F5 returning the 301/302 or is server behind the F5 returning the 301/302 and the F5 is just passing it along?

---

<div class="post-metadata">

**Author:** ![stan\_piron](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@stan\_piron](https://community.f5.com/u/stan_piron)\
**Post date:** [June 26, 2015, 10:04am UTC](https://community.f5.com/t/uri-rewrite-without-redirection/18938/3 "2015-06-26T10:04:33Z")

</div>

The following irule may answer your need:

```tcl
when HTTP_REQUEST
{
    HTTP::uri [string map {"/api/user.getInfo." "/api/user/getInfo."} [HTTP::uri]]
}

```

Your irule did not generate 302 respond but if your request is :

**[http://www.company.com/api/user/getInfo.test](http://www.company.com/api/user/getInfo.test)**

and getInfo.test is a directory on the web site, the web site will respond with a 302 to :

**[http://www.company.com/api/user/getInfo.test/](http://www.company.com/api/user/getInfo.test/)**

---

<div class="post-metadata">

**Author:** ![Richard\_The\_203](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@Richard\_The\_203](https://community.f5.com/u/Richard_The_203)\
**Post date:** [June 26, 2015, 10:56pm UTC](https://community.f5.com/t/uri-rewrite-without-redirection/18938/4 "2015-06-26T22:56:46Z")

</div>

Thank you for the verification!

Apparently, it was my server from the default\_pool that was returning 302 like you guys said. Specifying the pool in the iRule block fixed the issue.

```tcl
"/api/user.getInfo.*" 
{
  scan [HTTP::uri] {/api/user.getInfo.%[^.]+} cap1
  HTTP::uri /api/user/getInfo.$cap1
  pool my_api_pool
}

```
