Forum Discussion
Telnet_178675
Nimbostratus
Apr 11, 2015Regular Expression - HTTP URI
How can i match on following :
-http://www.xyz.com/abc/"anything" >>> I want to match on http://www.xyz.com/abc/ with anything after "/abc/"
-http://www.xyz.com/abc/QW"anything" >>> I wa...
John_Alam_45640
Apr 12, 2015Historic F5 Account
Here is an iRule that I shared with a few customers:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/abc"} {
set path [HTTP::uri]
variable loc marks the "Second" occurrence of a '/'. This will drop /abc
if you want to drop /abc/xyz, locate the "Third" occurence of '/' by changing 1 to 2 at
set loc [string first "/" $path 1]
set path_minus_root [string range $path $loc end]
Note: the value of variable path_minus_root will start with a '/'
HTTP::redirect "https://www.company.com/new_site/qux$path_minus_root"
}
}
You can also do this job using the [URI::path [HTTP::uri]] commands which are very useful.
https://devcentral.f5.com/wiki/iRules.URI.ashxRecent 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
