0

I want to force ssl and www for example.com to avoid SSL warnings (because my cert is for www

this is my .ebextensions/http_redirect.config configuration

files:
  "/etc/httpd/conf.d/httpd_redirect.conf" :
    mode: "000644"
    owner: root
    group: root
    content: |
      RewriteEngine On
      RewriteCond %{HTTP:X-Forwarded-Proto} !https
      RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

http://example.com is redirecting to https://example.com but since my ssl cert is for www.example.com I get a warning what needs to be changed to add www and https if is not in the request?

I can add www here

RewriteRule . https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

but I still need to figure out how to redirect to www to avoid the cert warning if the request was https://example.com

handsome
  • 2,335
  • 7
  • 45
  • 73
  • RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule . https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301] – Omar Tanti Mar 23 '18 at 03:54
  • To redirect from non-www to www: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L] - https://stackoverflow.com/questions/12050590/redirect-non-www-to-www-in-htaccess – Omar Tanti Mar 23 '18 at 03:57

0 Answers0