force https on any subdomain with a wildcard certificate

842 views Asked by At

My app allow users to create a page using a subdomain, so I have hundreds of subdomains.

I bought a Wildcard certificate and it works fine when you type the complete URL:

https://foo.mydomain.com
https://bar.mydomain.com
https://foo.mydomain.com/controller/method/argument
https://bar.mydomain.com?id=234

However I doesn't work if you miss to type HTTPS:// In that case you will be redirected to the root domain (mydomain.com)

My intention is to force HTTPS while keeping the URL.

This is what I have in my htaccess file

RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]

Thanks for your help.

0

There are 0 answers