I have a somehow specific setup. It really is due to some restrictions I cannot work around: There are domains 1. and 2. which I own and an external URL which I don't own:
- start.com
- root.com
- http://target.com/my/site?a=1
My goal is to redirect http://sub.start.com (and https://...) to http://target.com/my/site?a=1. Now to the restrictions:
- For 1. I can change dns entries. However, I cannot change anything on the http server itself. Also, the current setup is such that every http request is redirected to https. I also cannot alter the SSL certificate, which is not a wildcard certificate
- For 2. basically no restrictions. I can change everything on the server. (lighttpd) I can also get SSL certificates via Let's Encrypt.
- For 3. As mentioned, this is an external URL I don't own. It will also redirect any http request to https
How to achieve my goal? This is what I've setup so far:
- A DNS CNAME entry from "sub.start.com" to "sub.root.com" on 1.
- On root.com a redirect from sub.root.com to http://target.com/my/site?a=1
What works is the redirect http://sub.root.com to http://target.com/my/site?a=1. What doesnt work is:
- The redirect from https://sub.root.com to http://target.com/my/site?a=1 Returns a "insecure connection" message in firefox. This is because sub.root.com is not (yet) included in the SSL certificate. I can understand this issue. It is easy to fix.
- However, what I can't understand is that the redirect from http://sub.start.com does not work. This redirects me to https://sub.start.com and then complains that the certificate at root.com does not include sub.start.com. Why is this? I was expecting that the CNAME entry would "ignore" the server at start.com. The request should go directly to root.com, shouldn't it?
Also, is there a way to achieve my goal with this exact setup? I'm thinking to include sub.start.com and also sub.root.com to my SSL certificate at root.com. Would this take care of all the issues?