Apache2 https redirect to http without ssl cert

Apache2https

We have an apache server which hosts multiple domains from, which some have https enabled and some do not.

Now the problem is that if I access https://exampleWithoutHttps I will come to the content of https://exampleWithHttps.

I would like to forward the user from https://exampleWithoutHttps to http://exampleWithoutHttps on all domains whithout https. I have tried to create a redirect rule in virtualhost *:443 but this creates the following error:

Server should be SSL-aware but has no certificate configured

The problem is that I cant change "Listen 443" to "Listen 443 http" as this would break my hosts with ssl enabled.

Is there a way I could have a redirect without a ssl certificate ?

Or if not possible can you propose an alternative which would ensure that https://exampleWithoutHttps does not show the content of https://exampleWithHttps.

My ports.conf

NameVirtualHost *:80
Listen 80
NameVirtualHost *:443
Listen 443

mi site condfig:

<VirtualHost *:80>
 DocumentRoot /path/to/dr
 ServerName  exampleWithoutHttps.com
 ServerAlias www.exampleWithoutHttps.com
</VirtualHost>

<VirtualHost *:443>
 ServerName  exampleWithoutHttps.com
 ServerAlias www.exampleWithoutHttps.com
 Redirect permanent /   http://www.exampleWithoutHttps.com/
</VirtualHost>

Best Answer

Configure any certificate for your VirtualHost *:443 and you are done.

  • Could be simply a self-signed certificate that you generate for yourself. Of course user will see a security warning. This is expected. Users specifically want https where s stands for secure. You don't hold a valid certificate for exampleWithoutHttps.com, hence you cannot give them security - it's correct they are warned about that.
  • You could also get a valid cert for free from a couple of vendors.

Place the VirtualHost *:443 of ServerName exampleWithoutHttps.com before VirtualHost *:443 of ServerName exampleWithHttps.com. I mean place it textually as the first one in the Apache's configuration files. This ensures user will not see content from exampleWithHttps.

Related Topic