Forum Discussion
Bruce_Walker_11
Nimbostratus
Jun 21, 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 ...
hoolio
Cirrostratus
Jun 21, 2010Hi Bruce,
You can parse the value for a URI parameter using a slight change to URI::query:
URI::query "?&[HTTP::query] ¶m_name
So to parse the value of the Ntt parameter and use it in a URI rewrite, you can do something like this:
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"
}
}
Aaron
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