Forum Discussion
Bruce_Walker_11
Nimbostratus
Jun 22, 2010iRule for taking part of an original URI and inserting to a new URL
Hi there,
Was wondering what an iRule would look like that does the following:
Original URL:
Required URL: http://www.environment.domain/globalSearch?q=someuritocopy
The URI past the = could be of varying length.
Thanks,
Bruce
- hoolio
Cirrostratus
Hi Bruce,when HTTP_REQUEST { Check if some condition is true? if { [string tolower [HTTP::host]] eq "search.environment.domain" and [HTTP::path] eq "/listing" and [HTTP::query] contains "Ntt"}{ Rewrite the URI with the original path and the query string replaced with just the Ntt parameter value set for the q parameter HTTP::uri "/globalSearch?q=[URI::query "?&[HTTP::query] &Ntt]" Update the host header HTTP::header replace Host "www.environment.domain" } }
- Bruce_Walker_11
Nimbostratus
Hi Aaron,
when HTTP_REQUEST { Check if some condition is true? if { [string tolower [HTTP::host]] eq "search.devint.lpo" and [HTTP::path] eq "/listing" and [HTTP::query] contains "Ntt"} { Log the original Host and URI request log local0. "Original Client Request is: [HTTP::header value host][HTTP::uri]" Rewrite the URI with the original path and the query string replaced with just the Ntt parameter value set for the q parameter HTTP::uri "/globalSearch?q=[URI::query "?&[HTTP::query] &Ntt"]" Update the host header HTTP::header replace Host "www.devint.lpo" Log the modified Host and URI log local0. "Modified Client Request is: [HTTP::header value Host][HTTP::uri]" } }
- Bruce_Walker_11
Nimbostratus
FYI- It's BIG-IP Version 9.4.7 320.1 - hoolio
Cirrostratus
Hi Bruce,when HTTP_REQUEST { Check if some condition is true? if { [string tolower [HTTP::host]] eq "search.devint.lpo" and [HTTP::path] eq "/listing" and [HTTP::query] contains "Ntt"} { Log the original Host and URI request log local0. "Original Client Request is: [HTTP::header value host][HTTP::uri]" Rewrite the URI with the original path and the query string replaced with just the Ntt parameter value set for the q parameter HTTP::uri "/globalSearch?q=[URI::query "?&[HTTP::query] &Ntt"]" Update the host header HTTP::header replace Host "www.devint.lpo" } } when HTTP_REQUEST priority 501 { Log the modified Host and URI log local0. "(501) Modified Client Request is: [HTTP::header value Host][HTTP::uri]" }
- Kevin_Davies_40
Nacreous
Aaron,when HTTP_REQUEST { if it matches the request replace the request with a new one passing the old parameter. if { "[HTTP::host]/[HTTP::path]?[HTTP::query]" starts_with "search.devint.lpo/listing?Ntt=" } { HTTP::host "www.devint.lpo" HTTP::uri [concat "/globalSearch?q=" [URI::query "?[HTTP::query]" "Ntt"]] } } when HTTP_REQUEST priority 501 { ...as above... }
- hoolio
Cirrostratus
Hi Kevin, - Bruce_Walker_11
Nimbostratus
Hi Aaron and Kevin, - hoolio
Cirrostratus
Hi Kev,
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