0

I want to set up a http website:http://example1.com, and a https website:https://example2.com using the following configuration:

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.

3
  • You put both sites on https. Commented Mar 31, 2018 at 16:39
  • That's an idea. But the http site has been existed for long time, and the internal links and external links are all http links.Switching to https will damage SEO. Commented Apr 1, 2018 at 1:51
  • "Switching to https will damage SEO" is a ridiculous myth. That's what 301 is for. At this point, not switching will damage SEO. Commented Apr 2, 2018 at 3:36

1 Answer 1

0

I can also redirect one version to the other

That's exactly the correct solution here. Your Apache is now listening on both 80 and 443, and the VirtualHost matching is done within the connection, not before it. Therefore, your server must answer something, and a HTTP redirect to the canonical address would be ideal.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.