Secure https pages not resolving

Hullo there, Virtualminners!

I am in the process of upgrading my site to https, because I will be adding payment services which will require transfer of financial information.

Try as I might, I can not get the pages to resolve in https.

If I type “https://mydomain.com” in the address field, it DOES resolve to https, and give me the “lock” symbol and certificate information. So I think that all is set up correctly for security.

However, if I type “mydomain.com”, the page resolves to http://mydomain.com — not what I want. In fact, what I want is when anyone tries to go to any variation of the domain, including “http://mydomain.com”, that they be redirected to “https://mydomain.com”.

This is frustrating, as I thought I made the requisite changes in my Virtualmin panel. Particularly, this setting:

System settings / Virtualmin Configuration / SSL Settings / Redirect HTTP to HTTPS by default?

Is set to “Yes”.

Is there something I am missing? Let me know if you need any information that I have not provided.

Note that when I log into the Virtualmin panel, the Virtualmin panel pages do resolve to https,
i.e.: https://ded.mydomain.com:10000/virtual-server/…

My html files are located at: /home/mydomain/public_html/

Thanking you in advance.

-K

If you dont have create .htaccess file and add:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]

This will redirect anything to https://www so free to edit as you want, and it will work with any domain (just copy/paste).

Thank you, Diabolico.

I have used this htaccess method with other sites for which I do not have root access. I just thought that there might be a Virtualmin setting that would allow me to easily toggle this on/off. And I didn’t want to edit the apache config for fear of breaking it. :stuck_out_tongue:

This will work for now; but – anyone – if ever a better alternative arises, please let me know.

Diabolico and everyone: enjoy the coming weekend!

K