5

I'd like to redirect https://example.com to https://www.example.com for my PHP project on Google App Engine.

What I've done so far:

  1. Added and mapped the custom domains for both example.com and www.example.com.
  2. Updated the DNS with the provided records to redirect example.com to www.example.com.
  3. Uploaded an SSL that covers both example.com and www.example.com.
  4. Added "secure: always" in the app.yaml.

Here's what happens:

  1. http://example.com redirects to https://example.com.
  2. http://www.example.com redirects to https://www.example.com.

The website resolves properly for both URLs, but I'd prefer that the secure naked domain redirects to the secure www subdomain. I've researched all of the related posts on Stack Overflow, but can't seem to find anyone having the same issue.

Please help. Thanks!

  • Why can't you do that at the app level? https://stackoverflow.com/questions/7228653/redirect-non-www-to-www-urls – zengr Apr 25 '17 at 22:12
  • Thanks! I'll give it a try, then post my result. I'm new to web development, so there are a few things I still don't understand yet. But I'll try my best to figure it out. – Jimmy Jamma Apr 26 '17 at 03:51
  • The recommendation to redirect `http://example.com` to `https://www.example.com` is to do so in the application or use a third-party DNS platform. – Nicholas May 08 '17 at 18:50
  • 1
    @zengr: because App Engine does not use apache and thus does not use `.htaccess` files. – cpcallen Oct 16 '20 at 10:45

0 Answers0