Redirect particular hostname from https to httpd in httpd/apache2

Posted by webnothing on Server Fault See other posts from Server Fault or by webnothing
Published on 2013-10-24T23:50:01Z Indexed on 2013/10/25 3:57 UTC
Read the original article Hit count: 782

Filed under:
|
|
|

I have a webserver that has an ssl certificate applied to a subdomain https://shop.mydomain.com. I also have the hostname http://mydomain.com that has no ssl certificate. When invoking https://mydomain.com, browsers issue a warning that a certificate could not be verified because the webserver is identifying itself as https://shop.mydomain.com.

I would like all traffic that hits https://mydomain.com to be redirected to http://mydomain.com, and leave https://shop.mydomain.com as is.

My httpd.conf file generally looks like this:

< VirtualHost 122.11.11.21:80 >
ServerName shop.mydomain.com
.. regular old port 80 ..
< /VirtualHost >

< VirtualHost 122.11.11.21:443 >
ServerName shop.mydomain.com
.. SSL applies here ..
< /VirtualHost >

< VirtualHost 122.11.11.21:80 >
ServerName mydomain.com
.. regular old port 80 ..
< /VirtualHost >

It does not look as if I have SSL set up for https://mydomain.com yet one can invoke SSL mode and the browser identifies the connection as https://shop.mydomain.com. I need to redirect from https://mydomain.com because for some reason, Google has indexed my website with this url even though it shows a warning.

I have tried various methods to get this to redirect and nothing has worked.

Any help would be greatly appreciated.

© Server Fault or respective owner

Related posts about apache2

Related posts about redirect