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
16 Replies
- 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,
Thanks for your reply.
Yes, I want to change the URI in the server reponse before delivering it to the client.
I think the URI is in the location header.
Thanks,
Kapil - 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?
IE: Do you want the URI that the client sees to contain test?
It is unclear what you are attempting to accomplish.
-Brian - Kapil_Sharma_61
Nimbostratus
Hi Brian,
Yes I want exactly what you have written here:-) Can you please send me the irule code?
Thanks,
kapil - 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:
http://devcentral.f5.com/Default.aspx?tabid=29&articleType=ArticleView&articleId=33when 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.
Also Click here to read this doc for more info on the HTTP/URI commands: http://devcentral.f5.com/Default.aspx?tabid=29&articleType=ArticleView&articleId=32 - 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:
string first
string last
string range - Kapil_Sharma_61
Nimbostratus
Hi,
Maybe there was a misunderatnding. Let me explain again:
The client will request:
http://www.blah.com/sample/page.html
Now the URL should change to the following and gets delivered back to the client:
http://www.blah.com/test/sample/page.html
I think it will need HTTP_RESPONSE rule.
Thanks,
Kapil
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