Forum Discussion
pedinopa_170325
Nimbostratus
Aug 07, 2018trouble rewiting path
I need to rewrite the REQUEST path that is returned to the browser. I have an irule which reads the REQUEST path, splits it into a variable which has the path I want (I logged it to my logging serve...
Andy_McGrath
Cumulonimbus
Aug 08, 2018A few issues with your iRule, you are looking at the HTTP::path for a Query parameter which will never exist. Lets say the request is
https://some.host.com/this/is/the/path?jsessionid=thequerypart
You would get the following returned from different iRule commands:
- HTTP::host =
some.host.com
- HTTP::path =
/this/is/the/path
- HTTP::uri =
/this/is/the/path?jsessionid=thequerypart
- HTTP::query =
jsessionid=thequerypart
Your iRule would never find locate the
jsessionid
query and is only updating the HTTP path not the query.
The following iRule does the same but using
HTTP::uri
instead of HTTP::path
:
First use hsl::open to define where to send logs and save it as a variable HSL
when CLIENT_ACCEPTED {
set hsl [HSL::open -proto UDP -pool graylog2-syslog-pool]
}
when HTTP_REQUEST {
Check if the URI contains a jsessionid
if {[HTTP::uri] contains ";jsessionid="}{
Create variable to hold modified URI, split on ;jsessionid
set nojsession [getfield [HTTP::uri] ";jsessionid=" 1]
Write to log verify that the if clause and the variable are correct
HSL::send $hsl "webmod This is the $nojsession without sessionid"
Replace the URI with the variable (modified URI without jsessionid)
HTTP::uri $nojsession
}
}
Quick note about this iRule if the request contains any query parameters after the
jsessionid
then they will be lost as the getfield
command only takes the first part of the URI.
e.g. If the URI requested is
/this/is/the/path?page=test;jsessionid=thequerypart;user=bob
the updated request would be /this/is/the/path?page=test
and the query parameter user=bob
would be lost.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