Forum Discussion
GaryZ_31658
Mar 28, 2006Historic F5 Account
Change Referer on inbound HTTP::header
I have an application that monitors the "Referer" in the header very specifically.
I need to change "https://domain.com/uri?important_server_data" TO "http://domain.com/uri?important_server_...
Mar 28, 2006
I'd just use the TCL builtin "string range" command to extract the content you want from the original referrer (you can specify a start index and end of string for the stopping point). Something like this should do the job:
when HTTP_REQUEST {
set referer [HTTP::header "Referer"]
if { $referer starts_with "https://" } {
log local0. "Found Referer header: $referer"
set newReferer "http://[string range $referer 8 end]"
log local0. "Changing Referer header to $newReferer"
HTTP::header replace "Referer" $newReferer
}
}I don't think you need to call the "header exists" command as the assignment into the referer will be empty if the header doesn't exist and then fail the next "starts_with" comparison.
If this still doesn't work, you might try removing the Referer header and then inserting the new one with the "HTTP::header remove" and "HTTP::header insert" commands. That should be equivalent to the "HTTP::header replace" command though...
-Joe
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
