【问题标题】:Avoid multiple page redirects Gatsby http -> https避免多页重定向 Gatsby http -> https
【发布时间】:2021-02-14 21:11:38
【问题描述】:

https://developers.google.com/speed/pagespeed/insights我看到我的速度真的因为上面的错误而延迟了。 我试图通过将包添加到 gatsby-config.js 来解决它,但它不起作用。在我的 site-config.js siteUrl 中:https://mysite.co。我该如何解决?

{
      resolve: 'gatsby-plugin-htaccess',
      options: {
        RewriteBase: '/custom/',
        https: true,
        SymLinksIfOwnerMatch: true,
        host: 'mysite.co',
        redirect: [
          'RewriteRule ^not-existing-url/?$ /existing-url [R=301,L,NE]',
          {
            from: 'http:mysite.co',
            to: 'https:mysite.co',
          },
        ],
      },
    },

【问题讨论】:

  • 重定向在服务器上配置。如果您使用 apache,那么您可能在其中编写了 .htaccess 文件。如果你使用 nginx 那么可能在/etc/nginx/sites-available/default

标签: redirect pagespeed http-redirect


【解决方案1】:

需要添加httpsgatsby-config.js

module.exports = {
  siteMetadata: {
    siteUrl: `https:mysite.co`
  },

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-10
    • 2018-12-19
    • 2021-11-18
    • 2016-07-11
    • 1970-01-01
    • 2013-04-15
    相关资源
    最近更新 更多