Loadmaster remove leading www. from URL

0

Hi,

I am searching for a content rule which removes the leading www. from a domain. We are using SSL offloading with a wildcard certificate. The certificate is valid for subdomain.domain.tld. If an end user (for some reason) tries to reach www.subdomain.domain.tld he will get a certificate warning. One important thing is that the rewrite rule should be general and match subdomain1.domain.tld, subdomain2.domain.tld, etc. For Apache mod_rewrite it would be something like

RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

Can anybody help?

Thanks!
Simon

3 comments

Avatar
James Rago -- K360 Technical Product Manager Official comment

Simon,

You can do one of two things:

1) Add a Cname to your DNS for www. which points to domain.com
2) You can use a Replace Header rule with the following:
Header Field: Host
Match String: www.domain.com
Value to replace: domain.com

Avatar
0
BallBearnigs

Thanks,

for your response. But I think both ways are not a solution for our specific problem. With a CNAME you can change the target IP address. But the hostheader which is sent by the client remains still the same. So your browser will still throw a SSL warning.
We have also tried the header rewrite. This doens't work aswell, as the the URL in the browser still remains the same. Only the request for the real server changes.

In my opinion only a proper redirect (eg 301) can be a solution. But as we have a HTTP and a HTTPS farm and redirecting everything to HTTPS (Redirect URL https://%h%s) I'm not sure when and how the redirect should be performed. In addition to that we need a generic solution, because of the amount of domains we can't do a rewrite for every domain. Thats why I thought of something like

RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

Avatar
0
James Rago -- K360 Technical Product Manager

Well you would need to add the cname and the rewrite rule and that should work since the client would request www which is an alias for domain.com. Once it comes into the LoadMaster it would hit the rewrite.

The only other option I can think of is to set up a not available redirection. You would need to create a content matching rule to look at the host header, and match the www.domain.com and tick fail on match. Then you would need to apply this rule to a Offloaded Virtual Service. You would add it in the HTTP Selection Rules. Then configure the Not available redirection handling to 302 and domain.com. This would need to be a static value and could not be a variable since we are stripping the www portion of the domain name.