Forum Discussion
Jason_44064
Sep 30, 2011Nimbostratus
Changing Host URL without Redirect - IRULE
Hey all, I have been poking around the forums and couldn't find the exact answer to the IRULE i would like to write; or if its even possible to write this rule. Here's my scena...
Michael_Yates
Sep 30, 2011Nimbostratus
I must have misread what you were needing.
In order to change the Browser URL from "gear.swimming.com" to "www.recreation.com" you are going to have to redirect. A 301 or 302 is your choice.
HTTP::redirect "http://www.recreation.com/swimming" = 302
HTTP::respond 301 Location "http://www.recreation.com/swimming" = 301
If www.recreation.com is using an alternate Virtual Server you will need to un-comment the bottom section and aim this iRule at the pool of servers that serve content for gear.swimming.com.
The HTTP::header replace will take care of any Host Header Issues.
If the content for gear.swimming.com is in the root directory of the site on the servers you will need to remove the "/swimming" URI, but allow any sub-directories to still function properly.
Try this and see if it works for you:
when HTTP_REQUEST {
If sites exist on the same Virtual Server, this will change the Browser URL and redirect back to this
Virtual Server. If they occupy seperate Virtual Servers it will redirect the traffic away from this
Virtual Server and the iRule will need to be split. First if on one Virtual Server, Second if on the
Second Virtual Server.
if { [HTTP::host] eq "gear.swimming.com" } {
HTTP::redirect "http://www.recreation.com/swimming"
}
if { [string tolower [HTTP::host]] equals "www.recreation.com" && [HTTP::uri] starts_with "/swimming" } {
In case of Host Headers, replace the Host Value
HTTP::header replace Host "gear.swimming.com"
Remove /swimming subdirectory
HTTP::uri [URI::path [HTTP::uri] 1 1]
You may or may not need to redirect the traffic to a different pool depending on your applicaiton setup
pool gear.swimming.com.server.pool
}
}
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