跳到正文
Skillpedia
安全75k · #2876

http-to-https

它能做什么

这项技能检查 Web 服务器是否将普通 HTTP 访问发送到安全的 HTTPS 地址。适用于运营网站的网站所有者和开发者。

适用场景

  • ✓当访客在输入域名时没有带 https,并进入了不安全版本的时候。
  • ✓当旧链接仍指向普通 http 地址的时候。
  • ✓当你设置新服务器或新托管服务商的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/http-to-https/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/http-to-https/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请确保我的网站会把所有 http 访问重定向到 https。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查普通地址是否以 301 重定向响应到对应的 HTTPS 地址,并保留完整路径。它会建议在服务器或 CDN 层面进行设置,并通过命令行请求进行测试。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Redirect HTTP to HTTPS

Without an HTTP-to-HTTPS redirect, users who type the domain without https:// or follow old links land on the insecure version of the site, exposing session cookies and form data to network attackers.

Quick Reference

  • Redirect http://example.com to https://example.com with HTTP 301 (permanent redirect)
  • Preserve the full path and query string in the redirect: https://$host$request_uri
  • Use 301 (not 302) so browsers and search engines cache the redirect and future requests go directly to HTTPS
  • Configure redirects at the server/CDN level — never rely on client-side JavaScript for security redirects
  • After validating HTTPS works, add HSTS to eliminate future HTTP requests entirely

Check

Test whether http://example.com redirects to https://example.com with a 301 status code. Check that the full URL path and query string are preserved in the redirect Location header.

Fix

Configure the web server to redirect all HTTP requests to HTTPS with a 301 status code, preserving the full request path. Verify the redirect with curl -I http://example.com.

Explain

Explain why redirecting HTTP to HTTPS is necessary, the difference between 301 and 302 redirects, and how HSTS can eliminate the redirect for returning users.

Code Review

Review server config, headers, forms, and integration points related to Redirect HTTP to HTTPS. Flag exact responses, cookies, or browser behaviors that violate the rule, and verify them against the effective production-like response.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/security/http-to-https

常见问题

为什么使用 301 而不是 302?

这项技能指出,301 是永久性的,因此浏览器和搜索引擎会缓存它,并在以后直接访问 HTTPS。

重定向应该用 JavaScript 实现吗?

不应该。这项技能指出,安全重定向应在服务器或 CDN 上配置,而不是在客户端代码中。

设置重定向之后还需要做什么?

这项技能建议添加 HSTS,以阻止之后的普通 HTTP 请求。

详情

作者的原始描述

Use when checking whether a web server is configured to redirect all HTTP traffic to HTTPS.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2876
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能