我想将 HTTP 流量重定向到 HTTPS,因为这是 PWA 的 Lighthouse 要求。我的网站是用 Gatsby 构建的。
我发现了像下面这样的各种插件,它们似乎暗示答案来自修改.htaccess文件。
https://www.gatsbyjs.org/packages/gatsby-plugin-htaccess/
对于上面的插件,我尝试了如下配置,没有通过PWA审计:
{
resolve: 'gatsby-plugin-htaccess',
options: {
RewriteBase: '/custom/',
https: true,
www: true,
SymLinksIfOwnerMatch: true,
host: 'av-site.com',
redirect: [
'RewriteRule ^not-existing-url/?$ /existing-url [R=301,L,NE]',
{
from: 'http:av-site.com',
to: 'https:av-site.com',
},
],
},
},
Run Code Online (Sandbox Code Playgroud)
谁能帮帮我吗?谢谢!
小智 6
确保在gatsby-config.js的siteURL是HTTPS
module.exports = {
siteMetadata: {
title: `example`,
description: ``,
author: `me`,
siteUrl: `https://example.com`
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2193 次 |
| 最近记录: |