-1

I'm trying to set up my cloud.google.com compute instance to only point to https but i'm really struggling trying to figure it out.

My use cases are:

  1. user connects to http://www.example.com -> should redirect to https://example.com
  2. user connects to http://example.com -> should redirect to https://example.com
  3. user connects to https://www.example.com -> should redirect to https://example.com

I currently have a certbot certificate installed for example.com but have no idea how to set up the cloud dns to do all the rerouting.

Thanks for the help.

Nic

Nico
  • 1,954
  • 2
  • 14
  • 18
  • 1
    CNAME record does not work this way to route and DNS knows nothing about the protocol used. There is a [Feature Request](https://issuetracker.google.com/70980380) for adding the URL redirect record to redirect host name to another URL (http://example.com to http://www.example.com) or another HTTPS URL ( http://example.com to https://www.example.com). However, you can accomplish your use cases by any sort of webserver to accept and rewrite the URL to HTTPS. Example is shown [here](https://stackoverflow.com/questions/29029049/best-practice-301-redirect-http-to-https-standard-domain) – KarthickN Dec 27 '17 at 23:46
  • Thanks. Apache rewrite was what i was looking for. – Nico Dec 28 '17 at 20:58

1 Answers1

0

The answer was to use mod rewrite in apache to rewrite my requests.

Nico
  • 1,954
  • 2
  • 14
  • 18