Apache default NameVirtualHost pitfall

I was wondering why when I type a domain or subdomain without virtualhost behind I come on my first virtualhost and not the default one.

I tried to rename the default into 000-default without solving the issue. My NameVirtualHost is defined with my server ip :

NameVirtualHost my_ip:80

and I tried

<VirtualHost _default_:80>

or

<VirtualHost *:80>

and at the beginning I forgot to add the ServerName in the default vhost. But none of these worked.

The solution is only to defined your vhost with your server ip :

<VirtualHost my_ip:80>
    ServerName myserver.tld
    ...

And do not forget to set your ssl certificate in your default ssl vhost since it will be the one sent during ssl negociation.

Le commentaires sont fermés.