Hi,
One thing to be aware of with using the same IP address and port for multiple domains is that you can't use HTTPS. Only one SSL certificate can be configured per virtual server.
Using your existing logic, you could redirect only if the URI doesn't start with /domaina, /domainb, or /domainc.
If you're redirecting, make sure to include the leading forward slash in the URI:
This:
HTTP::redirect http://[HTTP::host]domainA[HTTP:uri]
Should be this:
HTTP::redirect http://[HTTP::host]/domainA[HTTP::uri]
Here is an example using switch:
when HTTP_REQUEST {
set the host to lowercase and check the domain
switch [string tolower [domain [HTTP::host] 2]] {
domaina.com {
is the parsed domain domaina.com?
if the URI doesn't start with /domainA, redirect the client and prepend /domainA to the URI
if { not ([HTTP::path] starts_with "/domainA/")}{
HTTP::redirect http://[HTTP::host]/domainA[HTTP::uri]
}
stop processing the rule as we have a match
return
}
domainb.com {
if { not ([HTTP::path] starts_with "/domainB/")}{
HTTP::redirect http://[HTTP::host]/domainB[HTTP::uri]
}
return
}
domainc.com {
if { not ([HTTP::path] starts_with "/domainC/")}{
HTTP::redirect http://[HTTP::host]/domainC[HTTP::uri]
}
return
}
default {
take some default action
}
}
}
If you had a lot of domains to handle, it might be easier to maintain if you created a datagroup (class) containing the domains. You could then use the findclass command to search for the requested host in the class and perform the redirect. There is an approximate example in the Codeshare section (
Click here).
Hope this gets you started...
Aaron