<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>301 on Kevin&#39;s Blog</title>
    <link>https://bloglee.pages.dev/tags/301/</link>
    <description>Recent content in 301 on Kevin&#39;s Blog</description>
    <generator>Hugo</generator>
    <language>zh</language>
    <lastBuildDate>Tue, 25 Mar 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://bloglee.pages.dev/tags/301/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Cloudflare Pages 301 重定向</title>
      <link>https://bloglee.pages.dev/post/301-redirect-of-cloudflare-pages/</link>
      <pubDate>Tue, 25 Mar 2025 00:00:00 +0000</pubDate>
      <guid>https://bloglee.pages.dev/post/301-redirect-of-cloudflare-pages/</guid>
      <description>&lt;p&gt;在 Cloudflare 的 Page Rules（页面规则）中，你可以通过以下步骤设置 301 重定向，将 &lt;code&gt;www.example.com&lt;/code&gt; 重定向到 &lt;code&gt;example.com&lt;/code&gt;：&lt;/p&gt;&#xA;&lt;h3 id=&#34;步骤&#34;&gt;步骤：&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;登录 Cloudflare，进入你的 &lt;strong&gt;站点管理界面&lt;/strong&gt;。&lt;/li&gt;&#xA;&lt;li&gt;在左侧菜单中，点击 &lt;strong&gt;Rules&lt;/strong&gt;（规则），然后选择 &lt;strong&gt;Page Rules&lt;/strong&gt;（页面规则）。&lt;/li&gt;&#xA;&lt;li&gt;点击 &lt;strong&gt;Create Page Rule&lt;/strong&gt;（创建页面规则）。&lt;/li&gt;&#xA;&lt;li&gt;在 &lt;strong&gt;If the URL matches&lt;/strong&gt;（如果 URL 匹配）字段输入：&lt;code&gt;https://www.example.com/*&lt;/code&gt;&#xA;（注意 &lt;code&gt;*&lt;/code&gt; 号表示匹配 &lt;code&gt;www.example.com&lt;/code&gt; 下的所有路径）&lt;/li&gt;&#xA;&lt;li&gt;在 &lt;strong&gt;Then the settings are&lt;/strong&gt;（然后执行以下设置）中选择 &lt;strong&gt;Forwarding URL&lt;/strong&gt;（转发 URL）。&lt;/li&gt;&#xA;&lt;li&gt;在 &lt;strong&gt;Select status code&lt;/strong&gt;（选择状态码）下拉菜单中，选择 &lt;strong&gt;301 - Permanent Redirect&lt;/strong&gt;（301 - 永久重定向）。&lt;/li&gt;&#xA;&lt;li&gt;在 &lt;strong&gt;Enter destination URL&lt;/strong&gt;（输入目标 URL）中填入：&lt;code&gt;https://example.com/{$1}&lt;/code&gt;,（&lt;code&gt;$1&lt;/code&gt; 用于保留原始路径）&lt;/li&gt;&#xA;&lt;li&gt;勾选 &lt;code&gt;Preserve query string&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;点击 &lt;strong&gt;Save and Deploy&lt;/strong&gt;（保存并部署）。&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3 id=&#34;说明&#34;&gt;说明：&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;这样设置后，&lt;code&gt;www.example.com/abc&lt;/code&gt; 会自动 301 重定向到 &lt;code&gt;example.com/abc&lt;/code&gt;，确保所有子路径也正确跳转。&lt;/li&gt;&#xA;&lt;li&gt;301 重定向是永久性重定向，有利于 SEO，使搜索引擎知道 &lt;code&gt;example.com&lt;/code&gt; 是主站点。&lt;/li&gt;&#xA;&lt;li&gt;确保 &lt;code&gt;example.com&lt;/code&gt; 也在 Cloudflare 管理下，否则目标站点可能无法正确解析。&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;如果你的站点使用 Cloudflare 的 &lt;strong&gt;Redirect Rules&lt;/strong&gt;（重定向规则），你也可以在 &lt;strong&gt;Rules &amp;gt; Redirect Rules&lt;/strong&gt; 里进行类似的配置，推荐使用 &lt;strong&gt;301 永久重定向&lt;/strong&gt; 以优化 SEO。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
