Forum Discussion
URI, Host change with Pool selection
Hello all. I'm trying to write, what should be, a simple iRule to replace the host, and the first portion of the URI, leaving any remaining portion of the uri intact. Such as:
IF the request is:"http://apples/macintosh/forsale....."etc Replace it with:"http://oranges/naval/forsale..."etc and direct it to pool "oranges"
BUT if the request is NOT http://apples/macintosh/forsale.....etc such as:"http://apples/grannysmith/forsale..."etc then I just want to direct it to pool "apples"
Please help.
5 Replies
- Domai
Altostratus
when HTTP_REQUEST { if {[string tolower [HTTP::host]] equals "www.oranges.com"} { pool pool_oranges } elseif {[string tolower [HTTP::host]] equals "www.apples.com"} { pool pool_apples } else {reject} }
- Domai
Altostratus
Also instead of rejecting if the host is incorrect as I did before you can also redirect them to a http page or a default pool. Let me know if you need me to incorporate that as well. And pls test this in your dev/QA region before going to prod.
- Patrick_Mullane
Nimbostratus
Okay, let me take away the apples and oranges and get to what we're trying to really accomplish.
We're upgrading from an older version of SharePoint to 2013. Now in that process, our SharePoint team decided to change the structure of how things were laid out. I'm trying to come up with a way to change the URI to prevent the thousands of links we have embedded in non-sharepoint pages and other documents from "breaking". All they've done is added a "/dept/" in the structure such as:
OLD Document location: http://share/it/pizzaparty.docx
NEW Document location: http://share13/dept/it/pizzaparty.docx
The conversion is happening one department at a time, so based on the department "IT", I want to change the host from share to share13 (fairly easy) and insert "/dept/" in the front part of the URI(the part I can't get working) without messing with any trailing information in the remaining portion of the URI.
Here is the code I've come up with, but it's not working fully. It works with just http://share/it/ but not with anything trailing the "/it/"
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/it" } { HTTP::uri [string map -nocase {"/it/" "/dept/it/"} [HTTP::uri]] HTTP::header replace Host "share13" pool pool_share13 } else { pool pool_share } }
- nitass
Employee
Here is the code I've come up with, but it's not working fully. It works with just http://share/it/ but not with anything trailing the "/it/"
i do not see anything obviously wrong in the code. you are already using oneconnect profile, aren't you?
i think you may try tcpdump (on bigip) to see what the wrong is.
- Kevin_Stewart
Employee
Agreed. There doesn't seem to be anything wrong in particular. So when you say "but not with anything trailing the /it/", do you that if you did, for example, "/it/foo", that it does not change the URI to "/dept/it/foo"? An internal capture will tell you this definitively.
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