Forum Discussion
Steve_Brown_882
Mar 14, 2007Historic F5 Account
Newbie Question URI Rewrite
Hello All,
I am in need of some help with an irule to rewrite a uri and uri redirects. I have a url which is https://prepend-host.domain.com/whatever and I would like to rewrite this inbound to be https://host.domain.com/whatever dropping the prepend- from the url. I also need to add the prepend- back to the url on the outbound redirects. I think this should not be that hard to accomplish. I am already decrypting the ssl so I am crossing my fingers that a simple irule would do the trick. Thanks in advance!!!
2 Replies
- Steve_Brown_882Historic F5 AccountOk so I have dug a bit and gotten myself started. I have a dirty verion of the first half of my requirment. This appears to be working the way I want although I need to make it more generic so I can use it for multiple sub domains. What I am looking for now is help writting the other half of this. Which would add the begin- portion back to the responces.
when HTTP_REQUEST {
if {[HTTP::host] contains "begin-sub."} {
HTTP::header replace "Host" "sub.host.com"
log local0. "This is the new host: [HTTP::header "Host"]"
}
} - Steve_Brown_882Historic F5 AccountActually I have this working in a very dirty mannor with these two rules and a stream profile. However I could use some help with cleanning these up so that I am not replacing with hardcoded data.
when HTTP_REQUEST {
if {[HTTP::host] contains "prefix-"} {
HTTP::header replace "Host" "subhost.host.com"
log local0. "This is the new host: [HTTP::header "Host"]"
}
}
when HTTP_RESPONSE {
if {[HTTP::header "Location" ] starts_with "https://subhost."} {
HTTP::header replace "Location" "https://prefix-subhost.host.com/etc.asp"
log local0. "This is the new outbound host: [HTTP::header "Host"]"
}
}
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
