Forum Discussion
Jim_107778
Nimbostratus
Mar 03, 2009Best way to rewrite no redirect
All,
I've got an application that needs to re-write the url...not redirect. There is data being posted...so a redirect would lose the data.
So...
when HTTP_REQUEST...
hoolio
Cirrostratus
Mar 09, 2009Hi Jim,
I just missed your reply last week. If you want to check the host value, you can use HTTP::host (Click here). To rewrite the Host header value, you can use 'HTTP::header replace Host "newhost.example.com"' (Click here). To get/set the URI, you can use HTTP::uri (Click here).
So to rewrite the host and URI without the client seeing the change, you can use an iRule like this:
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: New request to [HTTP::host][HTTP::uri]"
Check host/uri (set to lowercase)
switch "[string tolower [HTTP::host][HTTP::uri]]" {
"www.home.com/specificfile.asp" {
Rewrite host/URI
HTTP::header replace Host "www.here.com"
HTTP::uri "/whatever.asp"
log local0. "[IP::client_addr]:[TCP::client_port]: Rewrite host/uri (1)"
}
"www.home.com/differentfile.asp" {
Rewrite host/URI
HTTP::header replace Host "www.here.com"
HTTP::uri "/another.asp"
log local0. "[IP::client_addr]:[TCP::client_port]: Rewrite host/uri (2)"
}
}
}
AaronHelp 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
