brettbeggs_1177
Apr 07, 2010Nimbostratus
iRule Request - strip sub domains
I'm trying to create an iRule that can be used similar to the following mod rewrite command:
RewriteCond %{HTTP_HOST} ^.+\.(.+)\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ https://%1.mydomain.com$1 [R=301,L]
What we're wanting is anything that hits https://*.sub.mydomain.com to be redirected to https://sub.mydomain.com. I guess i'm just not sure how to strip everything before sub.mydomain.com from the URL while maintaining whatever is in that first sub domain spot.
Ideally this single rule would work for any of these variants:
https://*.sub1.mydomain.com > https://sub1.mydomain.com
https://*.sub2.mydomain.com > https://sub2.mydomain.com
https://*.whatever.mydomain.com > https://whatever.mydomain.com
If it matters, the virtual server is configured with a wildcard ssl certificate *.mydomain.com so we're trying to avoid customers instinctively adding www. to the beginning of the url and getting a certificate error.
Thanks for helping!