Forum Discussion
Kapil_Sharma_61
Nimbostratus
Sep 14, 2005HTTP Response
Hi,
I am trying to add a prefix to the URI before sending the response to the client.
For example, the server responds with the URI /sample/page.html
and I want to send to the client /test/sample/page.html
Thanks,
kapil
- drteeth_127330Historic F5 AccountThis should work.
HTTP::uri "/test[HTTP::uri]"
- drteeth_127330Historic F5 AccountPerhaps I misunderstood. The above command can be used in HTTP_REQUEST to change the request URI before it is sent to the server. Yo say that you want to change the URI in the server response. Is this URI present in the HTML payload of the server, in the Location header of a redirect, or somewhere else? Thanks!
- Kapil_Sharma_61
Nimbostratus
Hi, - Brian_Gupta_115
Nimbostratus
Do you want the client to request http://www.blah.com/test/sample/page.html and then have the LB strip out "/test" from the URI sent to the server? - Kapil_Sharma_61
Nimbostratus
Hi Brian, - Brian_Gupta_115
Nimbostratus
You are going to need to use the findstring to extract a substing of the URI. (I wish there was a URI::shift method)Click here to see the following article for an explanation of findstring:when HTTP_REQUEST { set my_uri [HTTP::uri] if { $my_uri starts_with "/test/" } { log $my_uri set stringtostrip [getfield [HTTP::uri] / 1] log $stringtostrip set new_uri [findstring [ [HTTP::uri] ] $stringtostrip] log $new_uri set rewrite_uri [HTTP::host]$new_uri log $rewrite_uri HTTP::uri $rewrite_uri } } } when SERVER_CONNECTED { if { $usessl == 0 } { SSL::disable } }
- Brian_Gupta_115
Nimbostratus
I submitted before finishing... The log statements that are commented out are there for debugging, as you will most likely need to test and tweak... (The line that starts with "set rewrite_uri" needs to be updated to include the protocol and or port if you are using a non-standard port. - Brian_Gupta_115
Nimbostratus
Also once you debugged and tested you should be able to shorten the rule.. (There are a few too many variable declarations... (Not sure if it impacts efficiency) - unRuleY_95363Historic F5 AccountYou could also use the native Tcl string commands like:
- Kapil_Sharma_61
Nimbostratus
Hi,
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