Forum Discussion
URL path rewrite?
Hi all,
Is it possible to perform following redirection using iRules?
http://www.example.com -> node1 and node2 http://www.example.com/external -> node3 and node4 (and user sees http://www.example.com/external/... in the browser URL address bar)
I'm to iRules and sorry for the newbie question.
Thanks a lot. /ST Wong
4 Replies
- Cory_50405
Noctilucent
Try this, assuming pool node34 is defined with your nodes 3 and 4 as members, and pool node12 is defined with your nodes 1 and 2 as members:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.example.com" } { if { [string tolower [HTTP::uri]] equals "/external" } { pool node34 } else { pool node12 } }Also keep in mind this isn't redirection, only pool selection based on the client's request. No redirection should be needed here.
- ST_Wong
Cirrus
Sorry that I didn't make the question accurate enough.
http://www.example.com/external -> node3 and node4 (and user sees http://www.example.com/external/... in the browser URL address bar)
In this case, node3/node4 don't know the uri /external/. I've to strip the /external/ part and pass the rest of uri to node3 and node4, then add it back in response to client. Is it possible? Thanks a lot.
- Cory_50405
Noctilucent
Sure, just a simple change necessary to hide the /external from the nodes:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.example.com" } { if { [string tolower [HTTP::uri]] equals "/external" } { http::uri "/" pool node34 } else { pool node12 } } - ST_Wong
Cirrus
Thanks, but seems I also have to rewrite the uri in HTTP response so that user's browser will see http://www.example.com/external/... no matter what content is returned. I tried to do following but seems didn't work.
when HTTP_RESPONSE {
STREAM::disable if {[HTTP::header value Content-Type] contains "text"}{ STREAM::expression {@www.example.com/@www.example.com/external/@} STREAM::enable } }
Thanks.
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