I have looked everywhere for .htaccess code to forward all inbound ssl traffic to my site from non-www to www. Example https://example.com to https://www.example.com. My ssl cert is installed on www and all other requests to the main domain cause a browser error. I already have this working for non-ssl urls using .htaccess. Can someone please provide the proper code for ssl as well? RewriteEngine On rewriteCond %{HTTP_HOST} !^www.example.com$ rewriteCond %{SERVER_PORT}s ^(443(s)¦[0-9]+s)$ rewriteRule (.*) http%2://www.example.com/$1 [R=301,L]
Try: RewriteCond %{HTTPS} =on RewriteCond %{HTTP_HOST} !^www\.example\.com$ RewriteRule ^(.*) https://www.example.com/$1 [R=301,L] Code (markup):