Forum Discussion

Jesper_Hedin_42's avatar
Jesper_Hedin_42
Icon for Nimbostratus rankNimbostratus
Dec 16, 2005

Change a 302 response header

Hello.

 

 

I wonder how to write an iRule that rewrites this HTTP response header:

 

 

Location: http://domain.com:8080/application-1.0/appLogin.do

 

 

to this one:

 

 

Location: https://domain.com/application-1.0/appLogin.do

 

 

 

I am new to this and i have tried a lot but I just can not make it work. Any ideas?

 

 

 

...Jesper

 

  • Nevermind. I just found an honorable mention from the iRules contest that fixed my problem right away. Thanks, Juha Ranta for your iRule http_rewrite. It made my day.

     

     

    http://devcentral.f5.com/Default.aspx?tabid=75

     

     

    ...Jesper
  • This is old...but I haven't been able to find anywhere else where this has been addressed:

    This may be ugly; but I believe it will get the job done.

    ** Note, this will not redirect from HTTP to HTTPS -- It will only remove the :PORT designation **

    Please post a comment if you have found a better way to remove the port designation from an HTTP 302 Location Header.

    when HTTP_RESPONSE {
        if { [HTTP::is_redirect] } {
            HTTP::header replace Location "[URI::protocol [HTTP::header Location]]://[URI::host [HTTP::header Location]][URI::path [HTTP::header Location]][URI::basename [HTTP::header Location]]?[URI::query [HTTP::header Location]]"
        }
    }