Listen 80 Listen 443 NameVirtualHost *:80 NameVirtualHost *:443 <VirtualHost *:80> ServerName example1.com DocumentRoot /var/www/example1.com/public_html </VirtualHost> <VirtualHost *:443> ServerName example2.com DocumentRoot /var/www/example2.com/public_html SSLCertificateFile... SSLCertificateKeyFile... SSLEngine On </VirtualHost>
However, if I visit https://example1.com, I am redirected to https://example2.com. If I visit http://example2.com, I am redirected to http://example1.com. I would like https://example1.com and http://example2.com do not exist at all. How should I do? I know I can add two more virtual hosts to match the other version of the websites. I can also redirect one version to the other for the sake of SEO. But that is not natural. Imagine you set up only one https site and apache only listens on port 443, search engines will never be aware of the existence of the http version of the website, which has the best SEO effects. That is exactly what I want.