Forum Discussion
John_Comstock
Nimbostratus
Sep 13, 2006iRule for URL Re-write
I have a requirement to rewrite the URL that external business partners connect to for both HTTP and HTTPS (will terminate SSL on the BigIP) traffic to forward to internal web sites. Can anyone direct...
John_Comstock
Nimbostratus
Jun 04, 2007Our application was sending a 301 redirect back to the client with our internal url…
The iRule below addresses the 301 problem, by replacing the location if there is a 301 with the original host set in the request.
The tool I was using to test didn’t show the 301, (perhaps because the location host was the same as that originally requested) but the browser did go to the proper page.
when HTTP_REQUEST {
set myhost [HTTP::host]
set entry [findclass [HTTP::host] $::urlrewrite " "]
if {$entry != ""} {
log "Entry not null, replacing Host: [HTTP::host] with: $entry"
HTTP::header replace Host $entry
if {[HTTP::uri] starts_with "/"} {
HTTP::uri http://$entry[HTTP::uri]
}
}
}
when HTTP_RESPONSE {
if {[HTTP::status] contains "301"} {
if {$myhost != ""} {
set myuri [findstr [HTTP::header Location] ".com/" 5]
HTTP::header replace Location https://$myhost/$myuri
}
}
}
Now we just need to get the rule implemented in production and tested with our vendors.
John
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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