o motivo pelo qual você não vê a versão sem o www, é porque você está usando dois curingas para o IP *:443
com dois nomes de domínio diferentes. O Apache simplesmente usa o primeiro para usar o certificado.
Da documentação do Apache [1]:
The problem with using named virtual hosts over SSL is that named virtual hosts rely on knowing what hostname is being requested, and the request can't be read until the SSL connection is established. The ordinary behavior, then, is that the SSL connection is set up using the configuration in the default virtual host for the address where the connection was received.
Para usar um curinga, você precisa de um IP por certificado. Cada IP virtual será usado pelo Apache para redirecionar a solicitação de entrada SSL criptografada.
Para fazer isso:
- Adicione um IP virtual à interface (se assumirmos que é eth0, adicione um alias a ele)
- Atualize o arquivo
ports.conf
, adicione duas entradas:
- NameVirtualHost IP1: 443
- NameVirtualHost IP2: 443
-
Atualize seu vHost para ficar assim:
Site com o www
NomeDoServidor www.site.com
Site sem o www
ServerName site.com
EDITAR
Você também pode redirecionar todos os acessos recebidos de "site.com" para "www.site.com". Para fazer isso, remova o vHost para site.com
e adicione a seguinte linha:
ServerAlias site.com
Isso instruirá o Apache a usar o mesmo vHost para os dois domínios.
Se você deseja redirecionar todos os hits recebidos ( link e link ) para o domínio principal protegido ( link ), considere adicionar as seguintes instruções:
RewriteEngine On
RewriteCond %{HTTPS} off
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
site.com substituído por example.com por regras de falha de servidor
[1] link