With Apache 2.2, I am unable to prevent a certificate error when rewriting non-www SSL requests. I can get the rewrite to work, but the cert warning pops up BEFORE the redirection takes place. I've been moving variations of the code below in different locations in the conf files but can't seem to find the proper context.
httpd.conf
extra/httpd-vhosts.conf
extra/httpd-ssl.conf
<Directory "/var/www/html/domain">
RewriteEngine on
# redirect non-cert domains to non-secure original domain
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http:
//%{HTTP_HOST}/$1 [R=301,L]
#redirect non-www domain requests
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ http:
//www\.example\.com/$1 [R=301,L]
</Directory>
[edited by: jdMorgan at 1:24 pm (utc) on Apr 26, 2010]
[edit reason] example.com [/edit]