Forum Discussion
Tony_Lee_73702
Nimbostratus
Oct 13, 2005HTTP rewrite for lots of URLs
Hi all,
I've got a pair of 3400s running 9.0.5. I've created a HTTP-based VS load balancing traffic against a handful of IIS servers.
I'm in a web hosting environment and I've got a situation where I need to do URL rewrites for the each customer on the BigIP.
http://www.A.com/ ---> http://www.IIS_node.com/A
http://www.B.com/ ---> http://www.IIS_node.com/B
.
.
etc (there's a *significant* number of customers... at least 100)
I thought of using the following iRule and I want to see if it made sense.
-------------
when HTTP_REQUEST {
set http_host HTTP::host
switch http_host {
"www.A.com" {HTTP::redirect "http://www.my_vs.com/A/"}
"www.B.com" {HTTP::redirect "http://www.my_vs.com/B/"}
}
}
-------------
Thanks - AJ
12 Replies
- Brian_Gupta_115
Nimbostratus
Check out the following thread: Click here http://devcentral.f5.com/Default.aspx?tabid=28&forumid=5&postid=2078&view=topic - Tony_Lee_73702
Nimbostratus
Thanks Brian and Joe. Great info! I'll give that a try and let you know how it works out. - Tony_Lee_73702
Nimbostratus
This is a follow-on to my previous question... - All you need to do is replace the 192.168.1.1 with the host name. You'll also need to put in a check for the uri to avoid an infinite loop.
when HTTP_REQUEST { if { [string equal -nocase [HTTP::host] "www.foo.com"] and not ([string tolower [HTTP::uri]] starts_with "/foo") } { HTTP::redirect "http://[HTTP::host]/foo[HTTP::uri]" } }
- Tony_Lee_73702
Nimbostratus
Thanks a lot Joe! - AJ - Richard__HarlanHistoric F5 AccountAfter reading these posts we started playing around with the idea of moving or redirector to the BigIP. Two problem pop up, one which should not be a big problem in the future for us is there a way to do a nocase on a class. The second if is or business people have put + signs in there url is there a way I can put the + sign in the class? Thanks
- Colin_Walker_12Historic F5 AccountWell, both of these questions are accounted for with iRules.
if { [string tolower [HTTP::uri] ] contains "some_string" } { ...
- As for the case comparison, why don't you just store all your values in lower case in the redir_class and then convert the host and uri to lowercase before calling findclass?
when HTTP_REQUEST { log start set lookup [string tolower [HTTP::host][HTTP::uri]] log $lookup set mapping [findclass $lookup $::redir_class " "] if { "" ne $mapping } { redirect to "$mapping" log "[HTTP::host] to $mapping" } else { set mapping [findclass [string tolower [HTTP::host]] $::redir_class " "] if { "" ne $mapping } { redirect to "$mapping" log "[HTTP::host] to $mapping" } else { log "no hit [HTTP::host]" redirect to "http://www.deere.com" } } }
- Richard__HarlanHistoric F5 AccountThis is what I am entering into the class
- What version of the software are you running? I tested your string out on 9.2 and the GUI let me enter it into a string class.
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