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.
when HTTP_REQUEST {
if { !([string tolower [HTTP::host]] equals "www.foo.com") } {
HTTP::header replace Host "www.bar.com"
You may or may not need to redirect the traffic to a different pool
depending on your applicaiton setup
pool alternate.website.pool
}
}
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
}
}
The only way to change the Browser URL is through a redirect (you can mask the URL or URI to the server at will, but the Browser does a DNS Lookup to resolve the DNS Name to the IP Address). As soon as you redirect to change the browser URL you would no longer be in control in your situation and the External Hosting company takes over. The External Hosting company would then have to manipulate the sub-directory (/swimming) to look back at your system to get the content for gear.swimming.com.
Basically, they would have to do what you are trying to do from their end.
No. Not in the configuration that you described (gear.swimming.com being hosted behind an F5 and recreation.com/swimming being hosted by a Third Party). In this scenario you are going to have to talk to one or the other. If the situation was reversed (recreation.com/swimming was hosted behind an F5 and gear.swimming.com had the content and was hosted by a Third Party), you could get it to work.
For the F5 side, would the code you supplied above do the job for the F5 box?
In your scenario, no. In the reverse scenario mentioned above, yes.
will recreation.com domain get the credit in terms of SEO?
In your scenario gear.swimming.com will be the URL that you must use to see the content, so it will get the credit. In the reverse scenario, yes because the requests would be proxied through the F5 and then returned to the user.