Forum Discussion
gauravarora_370
Nimbostratus
Aug 28, 2018one rewrite url works and another does not.
Hello
I have written an iRule script to rewrite a url based on a condition-
http://intfilings.abc.gov/navigator_icm/?desktop=xyz should rewrite to
http://intfilings.abc.gov/EFiling...
Lee_Sutcliffe
Nacreous
Aug 29, 2018You have an error in your code, [HTTP::header uri] will look for a header called 'uri', whereas I assume you mean HTTP::uri.
You are also checking for the same header twice so I've put it in one 'if' statement as well as adding a couple of lines of logging that may help troubleshooting. You also may want to consider using string tolower if this is accessed via a browser as URI is case sensitive. Please try the following.
when HTTP_REQUEST {
if {[HTTP::header "Host"] equals "intfilings.abc.gov"} {
if {[HTTP::uri] starts_with "/navigator_icm"} {
log local0. "replacing host on URI: [HTTP::uri]"
HTTP::header replace Host "server1.ct.gov"
} elseif {[HTTP::uri] starts_with "/EFilingWeb"} {
log local0. "replacing host on URI: [HTTP::uri]"
HTTP::header replace Host "server2.ct.gov"
}
}
}
You can also perform the same functionality using LTM Traffic Policies, these are recommended for simple iRules such as these.
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