I want to achieve the following with htaccess for my domain ‘example.com’:
- Always add ‘https://’ before the domain name or change ‘http://’ into ‘https://’;
- Add prefix ‘www.’ before the domain name (after ‘https://’) if no prefix is used, and do not change other prefixes (like ‘mobile.’).
So ‘example.com’ or ‘http://example.com’ will change into: ‘https://www.example.com’ and
‘mobile.example.com’ or ‘http://mobile.example.com’ will change into ‘https://mobile.example.com’.
2
Answers
your
.htaccess
file should be :I use this simple .htaccess file to change http -> https and adding www if not set