jhallard
jhallard

Reputation: 23

How to forward all website.com requests to www.website.com on Google App Engine?

After much hardship I finally got an SSL cert installed on my website. Now, I can add the

secure:always

line to app.yaml file, which will redirect all link to https. This works great, except that custom domains on GAE don't work under the url

https://jhallard.com

they have to have the www in front, like

https://www.jhallard.com

So right now, if a user goes to www.jhallard.com, they get forwarded to https://www.jhallard.com version and everything is great. If they go website.com, they get forwarded to https://jhallard.com and the page doesn't load. How do I (in python on GAE) forward all domain requests to the www version?

Upvotes: 0

Views: 145

Answers (2)

jhallard
jhallard

Reputation: 23

Okay I found the solution, it's a work around but it took about 5 minutes, cost nothing and it works.

Go to cloudflare.com and sign up for a free account. Enter your website and all that jaz. You'll have to go to your domain host and change the name servers during this process (cloudflare will walk you through this process). Next, go to the options for your website, go to SSL settings and select Full SSL. Next go to the "Page Rules" page for your website, and set a forwarder from

https://website.com/*

to

https://www.website.com/$1

Wait a few minutes and all requests to your website will be forwarded to the https://www version. Make sure to add the secure: always option in your app.yaml file.

Upvotes: 0

Dmytro Sadovnychyi
Dmytro Sadovnychyi

Reputation: 6201

There're to ways to set up a custom domain for app engine application right now: with google apps and with new developers console.

In google apps you can simply add a naked domain redirect, so requests from website.com will be redirected on www.website.com.

With new developers console you are able to use your application on naked domain, our just connect both of them and redirect on www within your application code.

You can access it here:

https://console.developers.google.com/project/PROJECT_NAME/appengine/settings/domains/add

Upvotes: 1

Related Questions