Reputation: 33
I have certificate for www.example.com
It's working for now.
I want to redirect all requests with 'www' and non 'www' to https with 'www'
http://www.example.com to https://www.example.com
http://example.com to https://www.example.com
https://example.com to https://www.example.com
I am getting error that, 'Certificate is only valid for www.example.com'
How can i make redirections?
What i tried?
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
It's working on chrome. On firefox https://example.com is giving error that.
Your connection isn't secure.
I tried to clear history and cache for firefox. It's quite same.
Upvotes: 0
Views: 88
Reputation: 33
I found the solution.
Generated 1 certificate for 2 domains example.com and www.example.com
Followed instruction at here. Used that in .htaccess
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
And yay yay. All variants are working for all browsers including mobile.
Upvotes: 1