0

I'm using google cloud platform to host my site and namecheap for the domain name. I want any traffic that hits https://www.example.com to redirect to https://example.com.

I currently have http://www.example.com and http://example.com redirecting to https://example.com from using DNS URL redirects and having secure: always as a handler in my app.yaml file (for ruby on rails).

I dont know how to have https://www.example.com redirect to https://example.com. I've tried adding a .htaccess file but couldn't get it to work so maybe there is a configuration I can have in the app.yaml file or some other way for this to work.

Rob
  • 1,835
  • 2
  • 25
  • 53
  • @DanCornilescu that link is for python and isnt quite the same problem unfortunately – Rob May 21 '16 at 07:39
  • Can you link to what Google Cloud Publisher is? A [quick web search](https://www.google.com/?q=google%20cloud%20publisher) only shows links to [Google Cloud Pub/Sub](https://www.google.com/?q=google%20cloud%20publisher), which is presumably not the product you're talking about. – E. Anderson May 27 '16 at 05:39
  • @E.Anderson Sorry it was a typo for 'platform' (yea it was pretty late when I wrote this up) – Rob May 27 '16 at 07:19

1 Answers1

1

It sounds like you're using App Engine in particular.

I don't think that app.yaml supports matching on the hostname; you can either implement the redirect in your application or add a second service to your app which only serves the redirects and use dispatch.yaml to route requests to non-canonical domain to the redirect service.

Sample dispatch.yaml if you decide to use two services:

dispatch:
  # Official site is at example.com
  - url: "example.com/*"
    module: default

  # Default module serves simple redirect.
  - url: "*/*"
    module: redirect
Community
  • 1
  • 1
E. Anderson
  • 3,405
  • 1
  • 16
  • 19
  • It doesnt look like these solutions work for https redirecting. I have http redirecting working from the app.yaml file. – Rob May 31 '16 at 00:39