Forum Discussion
Kenny_Van_73892
Nimbostratus
Feb 12, 2009strip away www. and redirect to https:// without cert mismatch error
I need some help to clear my mind.
I need to strip away www. from host either on port 80 or 443 and redirect to https://. For instance, if user enters http or https://www.sub.mycompany.com then it must get stripped away www. and redirects to https://sub.mycompany.com, if user enters http or https://sub.mycompany.com then it just redirects to https://sub.mycompany.com.
I came up with this, but couldn't get it to work the way I wanted and got certificate error because the host didn't match with registered SSL host as sub.mycompany.com.
if {[HTTP::host] starts_with "www." and [TCP::local_port] eq 80 or [TCP::local_port] eq 443} {
HTTP::redirect https://www.sub.mycompany.com [string range [HTTP::host] 4 end][HTTP::uri]
} elseif { [TCP::local_port] eq 80 } {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
So, how do I strip the www. away and cert won't complain mismatch?
Thanks in advance.
- dennypayne
Employee
Unfortunately there's really not a way to do this other than getting a wildcard cert that will match both names. - Kenny_Van_73892
Nimbostratus
So, https://www.sub.mycompany.com not equal as https://sub.mycompany.com ? Somehow I thought www is generic and shouldn't be matter. - Kenny_Van_73892
Nimbostratus
I did some searches on this forum but wonder if this would work or not - Kenny_Van_73892
Nimbostratus
Now I have another question and would like to get a confirm that if I can get CA such as Verisign to issue a SSL cert to www.sub.mycompany.com and sub.mycompany.com then this would re solve the whole mismatch cert? and user can either enter https://www.sub.mycompany.com or https://sub.mycompany.com and get directed to a single VIP on Big IP. - Russell_E_Glaue
Nimbostratus
We actually do exactly what you are doing at our operations, just in a different approach. - Russell_E_Glaue
Nimbostratus
Posted By puma on 02/19/2009 6:54 AM
- Russell_E_Glaue
Nimbostratus
Do note, however, that each SSL Cert and matching domain must be assigned to, and responding on, two different IP numbers - Kenny_Van_73892
Nimbostratus
Thanks a lot RG. Your quick response cleared up my head. - hoolio
Cirrostratus
Actually, you can get a single CA signed cert that is valid for multiple subjects like example.com and www.example.com (or even www.example.com and www.example.co.uk), using Subject Alternate Names (SANs). Most modern browsers support SANs. Try searching the iRule and/or Advanced Config forums for some related links. - Russell_E_Glaue
Nimbostratus
Regarding Subject Alternate Name SSL Certificates
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