Forum Discussion
I need to rewrite a URI between the F5 and Server only
I have a situation where I would like to remove a directory from the URI but keep all other information in tact.
example: Between the Client and F5 I need https://www.company.com/information/any_directory_name/any_pgm_name.aspx Between the F5 and Server I need https://www.company.com/any_directory_name/any_pgm_name.aspx
I do not want the client to know the "/information" directory is missing from the internal request/response. What do I need to do on the F5 to rewrite the URI for request and response? If this can be done easily within the GUI how would I config it?
This is not working.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { {HTTP::uri string map { "/information" "" } } }}
4 Replies
- Kevin_Stewart
Employee
Try this:
when HTTP_REQUEST { HTTP::uri [string map {"/information" ""} [HTTP::uri]] }The above will brute force remove any instance of "/information" in the client side request URI. It will not, however, insert the URI into responses. Not sure if that's necessary, so not touching on possible solutions here.
- Mike_Smith_1088
Nimbostratus
Thanks Kevin That definitely helped, but it is only half my issue. I do need to add the "/information" directory back to the beginning of the URI and send back to the client.
- Mathew_Loesch
Nimbostratus
Will this work??
when HTTP_REQUEST {
set client_uri [HTTP::uri] set client_host [HTTP::host] HTTP::uri [string map {"/information" ""} [HTTP::uri]] } when HTTP_RESPONSE { HTTP::respond "http://$client_host$client_uri" } - Wand_97484
Nimbostratus
try the Stream Profile: https://devcentral.f5.com/wiki/iRules.STREAM__expression.ashx
try the 1st example and remove /information as suggested earlier in the HTTP_REQUEST part.
In the HTTP_RESPONSE stream::expression use:
"@https://www.company.com/@ @https://www.company.com/information/@"
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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