I have an apache2 webserver in AWS using bitnami. In my bitnami.conf
file I need to rewrite all URLs to
https://www.example.com
I am able to redirect the following correctly
mydomain.com
http://example.com
www.example.com
But when the url is https://example.com
it does not redirect to https://www.example.com.
my configuration is
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ - [E=protossl:s]
RewriteCond %{HTTP_HOST} ^([a-z.]+)?example.com$ [NC]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule .? http://www.%example.com%{REQUEST_URI} [R=301,L]
RewriteRule /smecweb/(.*) /$1 [R=301]
RewriteRule ^(/(.*))?$ https://www.%{SERVER_NAME}/$1 [R,L]
I tried to do something similar in <VirtualHost _default_:443>
, but reverted it.
Can someone point out what am I doing wrong here?