# How can I get rid of the port on redirects.

**URL:** <https://community.f5.com/t/how-can-i-get-rid-of-the-port-on-redirects/29881>\
**Category:** Technical Forums\
**Tags:** irules, dev, devops, application-delivery\
**Created:** [May 18, 2009, 3:16pm UTC](https://community.f5.com/t/how-can-i-get-rid-of-the-port-on-redirects/29881 "2009-05-18T15:16:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiamars\_51328](https://avatars.discourse-cdn.com/v4/letter/k/85f322/32.png) [@kiamars\_51328](https://community.f5.com/u/kiamars_51328)\
**Post date:** [May 18, 2009, 3:16pm UTC](https://community.f5.com/t/how-can-i-get-rid-of-the-port-on-redirects/29881/1 "2009-05-18T15:16:10Z")

</div>

Hi, I can redirect to new port, but how can i elemenated the port, I don’t want to see the port that I am redirecting.

thx for your time.

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [May 18, 2009, 3:56pm UTC](https://community.f5.com/t/how-can-i-get-rid-of-the-port-on-redirects/29881/2 "2009-05-18T15:56:19Z")

</div>

Hi,

Here is a Codeshare example which shows how to remove the port from the Location header value in 30x redirects:

[http://devcentral.f5.com/wiki/default.aspx/iRules/RewriteHTTPRedirectPort.html](http://devcentral.f5.com/wiki/default.aspx/iRules/RewriteHTTPRedirectPort.html)

```tcl
when HTTP_RESPONSE { 
  
     Check if server response is a redirect 
    if { [HTTP::header is_redirect]} { 
  
        Log original and updated values 
       log local0. "Original Location header value: [HTTP::header value Location],\ 
          updated: [string map ":[TCP::remote_port]/ /" [HTTP::header value Location]]" 
  
        Do the update 
       HTTP::header replace Location [string map ":[TCP::remote_port]/ /" [HTTP::header value Location]] 
    } 
 }

```

Aaron
