# URI Rewrite for Server Pool

**URL:** <https://community.f5.com/t/uri-rewrite-for-server-pool/61830>\
**Category:** Technical Forums\
**Tags:** irules, devops, application-delivery, irule-editor\
**Created:** [November 14, 2006, 1:16am UTC](https://community.f5.com/t/uri-rewrite-for-server-pool/61830 "2006-11-14T01:16:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Yates](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Michael\_Yates](https://community.f5.com/u/Michael_Yates)\
**Post date:** [November 14, 2006, 1:16am UTC](https://community.f5.com/t/uri-rewrite-for-server-pool/61830/1 "2006-11-14T01:16:48Z")

</div>

I have an issue which after reviewing numerous other posts…isn’t covered.

I have a site connected to a server pool that is accessed by a normal URL ([http://website.domain.com](http://website.domain.com)), but returns the server name, access port, and directory ([http://servername:5555/directory](http://servername:5555/directory)).

The problem is that I need the Server Name Portion stripped on the return to the Browser, but the IRule needs to be able to do this for a Server Pool of 2 or more servers.

In addition anything past the URI / must remain unchanged. I’ve tried several solutions the following being the last to no avail.

when HTTP\_RESPONSE\_CONTINUE {

set newhost “[http://website.domain.com](http://website.domain.com)”

if { [HTTP::header host] contains “servername:5555/” } {

HTTP::header replace host $newhost

}

}

Can someone help me or point me in the right direction?

---

<div class="post-metadata">

**Author:** ![Joe\_Pruitt](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/joe_pruitt/32/8438_2.png) [@Joe\_Pruitt](https://community.f5.com/u/Joe_Pruitt)\
**Post date:** [November 15, 2006, 9:12pm UTC](https://community.f5.com/t/uri-rewrite-for-server-pool/61830/2 "2006-11-15T21:12:02Z")

</div>

A few corrections. In the HTTP protocol, the server does not return a server name and location as part of the HTTP response.

Here’s a trace for a request for [http://www.foo.com/index.html](http://www.foo.com/index.html)

GET /index.html HTTP/1.0

User-Agent: browser-id-string

Host: [www.foo.com](http://www.foo.com)

Pragma: no-cache

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, \*/\*

and here’s the response:

HTTP/1.1 200 OK

Date: Wed, 15 Nov 2006 19:00:12 GMT

Server: server-id-string

Last-Modified: Fri, 18 Mar 2005 15:33:33 GMT

ETag: “75e5-ced-19dd0d40”

Accept-Ranges: bytes

Content-Length: 3309

Connection: close

Content-Type: text/html; charset=ISO-8859-1

Content…

As you’ll see there is no Host header in the response, nor any host or uri indication whatsoever.

The URI in the browser is based on the URL in the initial request. A server can opt to change this by issuing a HTTP Redirect (ie. a HTTP 301 response) to the browser with the Location Header containing the alternate URL to then connect to.

With that being said, I can only assume that you would like the BIG-IP and iRules to do the 30x redirection for you. This can be done by changing the Host header in the request like this

```tcl
HTTP::header replace "Host" "servername:5555"

```

and changing the URI with the HTTP::uri command

```tcl
HTTP::uri "/directory[HTTP::uri]"

```

You may want to do something different with the uri but you get the point.

One other thing I noticied is that you took the host to contain the protocol (ie http://). This is not the case. The host is the section right after the protocol and before the first slash.

So for this uri: [http://servername:5555/directory/index.txt](http://servername:5555/directory/index.txt), the value of HTTP::host is “servername:5555” and HTTP::uri is “/directory/index.txt”.

BTW, in the future, you might want to post these types of questions to the iRules v9x forum as this forum is for questions regarding the iRules Editor application.

-Joe

---

<div class="post-metadata">

**Author:** ![bob\_chen\_103251](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@bob\_chen\_103251](https://community.f5.com/u/bob_chen_103251)\
**Post date:** [November 23, 2006, 9:34am UTC](https://community.f5.com/t/uri-rewrite-for-server-pool/61830/3 "2006-11-23T09:34:38Z")

</div>

ok
