GoDaddy 自定义域映射到 AppEngine (Flex/Node) 使用 www 时出现 404s

GoDaddy custom domain Mapped to AppEngine (Flex/Node) 404s when using www

我正在尝试在域 http://www.nickjonas.nyc and I'm just getting 404 errors from Google's end. When you go to http://nickjonas.nyc 中使用“www”,它工作正常。

这是我的 DNS 在 GoDaddy 上的样子:

这是 AppEngine 设置中的样子:

这是我的 app.yaml:

runtime: nodejs
env: flex

这是我的 app.js:

// [START gae_flex_node_static_files]
'use strict';

const express = require('express');
const app = express();

app.set('view engine', 'pug');

// Use the built-in express middleware for serving static files from './public'
app.use('/static', express.static('public'));

app.get('/', (req, res) => {
  res.render('index');
});

// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});

// [END gae_flex_node_static_files]
module.exports = app;

我看到在您的 GoDaddy 域配置中,您正在为域的 www 设置 CNAME 别名。我看不到的是,如果您还配置了 www subdomain inside the App Engine custom domain mappings. The App Engine documentation 指出您必须在配置期间添加要映射的子域,建议映射 www 子域:

  1. In the Point your domain to [project-ID] section, specify the domain and subdomains that you want to map.

We recommend mapping the naked domain and the www subdomain. You can add more subdomains if you need them. When you've added all the mappings you want, click Save mappings.

您的 App Engine 配置屏幕截图没有显示它,但它应该如图所示 here 显示 www 子域和列表中的实际域。

至少有两种方法可以删除 404

  1. 在 Google App Engine 设置页面上,您必须将您的裸域和 www 域映射到您的项目 ID,即重复您对当前在屏幕上显示的内容执行的步骤为 www 子域拍摄。这意味着您的页面基本上可以通过 2 url 秒访问。如果这样做,您应该通过设置 canonical url 来告诉 Google 要抓取哪一个。参见 documentation

  2. 第二个选项是保留您当前拥有的内容,然后在 GoDaddy 设置中添加 domain forwarding 以将 http://www.nickjonas.nyc 转发到 http://nickjonas.nyc。这意味着如果用户在浏览器中输入 http://www.nickjonas.nyc,它会将他们重定向到 http://nickjonas.nyc 此方法的优点是您没有与方法 1 相关的重复 url 问题.