Forum Discussion
tidenz_92110
Nimbostratus
Mar 24, 2010Location rewrite redirect 302 string issues
New to string commands and irules but i am trying to do a header replace without using regex.
In the redirect location header I am trying to strip out the protocol and the hostname to m...
hoolio
Cirrostratus
Mar 24, 2010Hi Tidenz,
You can use scan for this:
when HTTP_RESPONSE {
Check if response is a redirect
if { [HTTP::is_redirect] }{
Use scan to check for http://$host/$uri, saving the matches
the leading / of the URI will be trimmed, so we need to append it in the Location rewrite
if {[scan [HTTP::header Location] {http://%[^/]/%s} host uri] == 2}{
HTTP::header replace Location "/$uri"
}
}
}
This assumes that the Location value always starts with http:// and has at least one character after the third slash in http://www.example.com/. If it could be https:// also, let me know and I'll try something else.
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
