Forum Discussion
joelvs_45274
Nimbostratus
Sep 14, 2007Redirect HTTP traffic without modifying url
Hello,
I am repeatedly getting requests from my developers to have blah.domain.com display a page that is at www.domain.com/uri without changing the original url. They want the original url...
Sep 14, 2007
Let's assume your external hostname is "blah.domain.com" and your internal servers are configured with a hostname of "www.domain.com", then you can use simple host name header rewriting to do the trick.
when HTTP_REQUEST {
if { [HTTP::host] eq "blah.domain.com" } {
HTTP::header replace "Host" "www.domain.com"
}
}This will change the Host header going to the backend webserver from blah.domain.com to "www.domain.com" so a request for "http://blah.domain.com/foobar" would look like "http://www.domain.com/foobar" to the backend server.
Now for your specific question, you mention that you would like "blah.domain.com" to be treated like "www.domain.com/uri. It's a bit unclear on whether you are asking to redirect all "http://blah.domain.com/something" requests to "http://www.domain.com/fixeduri" where "something" and "fixeduri" are different values or whether you are just asking to keep the uri portion of the request the same. If it's the same, then the above iRule will work for you as it doesn't modify the original URI.
Now if you did want to map all incoming requests to a fixed URI, you could do something like the following:
when HTTP_REQUEST {
if { [HTTP::host] eq "blah.domain.com" } {
HTTP::header replace "Host" "www.domain.com"
HTTP::uri "/fixedvalue"
}
}This will turn all requests to "http://blah.domain.com/..." to "http://www.domain.com/fixedvalue".
Since these iRules are just modifying HTTP header values to the backend server, they will not be reflected in the browsers address bar as they would if being sent a HTTP redirect.
Let me know if this suits your needs and if not, some more concrete examples of mappings you want to perform.
-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
