Forum Discussion
kai_wang_48807
Nimbostratus
Jan 30, 2007Help! how to Change request URL without Redirect
Hope result:
When Client access URL is http://abc.com/abc, iRule will chang it to http://abc.com/123/bac/... and send to server.
Notice: couldn't use http:redirect uri, since client couldn't support redirect.
Please give me some direction!
Thanks.
4 Replies
- You can modify the URI with the HTTP::uri command. This should be pretty close to what you want.
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/abc" } { HTTP::uri [string map -nocase {"/abc" "/123/bac"} [HTTP::uri]] } }
What this does is for all URI's that start with "/abc", it will replace the "/abc" with the string "/123/bac"http://foo.com/abc -> http://foo.com/123/bac
http://foo.com/abc/file.ext -> http://foo.com/123/bac/file.gif
One gotcha to watch out for is that the string map command will replace all occurances of the first string with the second. So this would also happen which may or may not cause you issues.http://foo.com/zzz/abc.ext -> http://foo.com/zzz/123/bac.gif
If that is an issue, then you may want to do something like this using findstr to strip out the initial characters in the URI.when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/abc" } { HTTP::uri "/123/bac[findstr [string tolower [HTTP::uri]] "/abc" 4]" } }
This one can have some gotchas as well...http://foo.com/abc.gif -> http://foo.com/123/bac.gif
Only you know your web application so you'll have to account for all these subtleties and work around them. But for your initial question, at least one of these should work for you.
-Joe - kai_wang_48807
Nimbostratus
Thanks a lot!
It's very usefull. - Jon_Strabala_46
Nimbostratus
Can you modify the port (without Redirect) from say 8080 to 80 if so how - hoolio
Cirrostratus
Hi Jon,
Do you mean the TCP port of the destination? If so, LTM will do destination port translation from the client's destination port to the selected pool member's port as long as port translation is enabled on the VIP. If you mean rewriting the TCP port in the Host header, you can use the HTTP::host command to do this:
HTTP::header replace Host [string map {:8080 :80} [HTTP::host]]
Aaron
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