I am currently working on an application which was build to work with wildcard subdomains.
For Example:
customer1.domain.com
customer2.domain.com
So we bought a wildcard SSL Certificate for *.domain.com and redirected all subdomains from http to https.
So far, so easy, but now we have customers that manually type www.customer1.domain.com in their browser, for this exists no vhost.
What i want to do now is, redirect all request from http://www.wildcard.domain.com to https://wildcard.domain.com
Our vhost looks like:
<VirtualHost {{IP-ADRR}}:443>
Servername %1.domain.com
VirtualDocumentRoot /path/to/webroot/%0
Include /etc/httpd/conf/options-ssl-standard.conf
</VirtualHost>
Our Redirect for all HTTP Request to same target on HTTPS looks like:
<Virtualhost {{IP-ADRR}}:80>
ServerName %1.domain.com
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>