Forum Discussion
Phil_Rudich_735
Nimbostratus
Nov 07, 2007URI Rewrite
Hey all! I'm new to F5 and iRules and need some assistance.
Looking to take an original URL and perform a rewrite to another site so that the client does not know the true URL address. Thi...
Nov 07, 2007
The main issue I can see is that you are rewriting ALL uri's to "/AAEP/". All requests into the site (including image requests) will be rewritten.
http://www.yyy.mycompany.com/ -> http://zzz.mycompany.com/AAEP/
http://www.yyy.mycompany.com/foobar -> http://zzz.mycompany.com/AAEP/
http://www.yyy.mycompany.com/image.gif -> http://zzz.mycompany.com/AAEP/
...
Obviously not what you want to do. Since I have no background on your application, only you can figure out which URI's you need to rewrite. But, odds are you will have to do some sort of conditional test on the value of HTTP::uri before rewriting the URI. With something like the following.
when HTTP_REQUEST {
switch [HTTP::host] {
"www.yyy.mycompany.com" {
HTTP::header replace "Host" "zzz.mycompany.com"
switch -glob [HTTP::uri] {
"/" -
"/index.html" -
"/default.aspx" {
HTTP::uri "/AAEP/"
}
}
}
}
}One more thing, if you are only comparing one value for the host, an IF statement might be easier to read. There isn't much performance gain on a switch when you are only doing one comparison.
when HTTP_REQUEST {
if { [HTTP::host] equals "www.yyy.mycompany.com" } {
HTTP::header replace "Host" "zzz.mycompany.com"
switch -glob [HTTP::uri] {
"/" -
"/index.html" -
"/default.aspx" {
HTTP::uri "/AAEP/"
}
}
}
}Hope this helps...
-Joe
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