💡 Preliminary Notes: With this tutorial, you'll learn how to automatically redirect users to a specified URL when they visit your domain.
⚠️ Important Reminder: After changing a domain name's DNS servers, it takes some time for the changes to take effect (typically anywhere from several tens of minutes to 24 hours, and up to 48 hours). Please be patient after completing the configuration,Don't test repeatedly.。
📑 Table of Contents
Step 1: Add a domain to Cloudflare
- Log in to the Cloudflare dashboard and click on the left-hand menu's Domians(Domain Name) → Overview(Overview), then click Add site(Add a site).
- Enter your own domain name and click "Continue."
- Select Free(Free) Plan—after confirmation, proceed to the next step.

Step 2: Add 2 DNS records (the Orange Proxy must be enabled)
✅ Key Points: The IP address entered here is a sample virtual address,You do not need to replace this with your own server's IP address.。
Add the following two lines A Record:
| Type | Host Records | Recorded values | Agent Status |
|---|---|---|---|
| A | @ |
192.0.2.1 |
Enable Orange Cloud (Proxy) |
| A | www |
192.0.2.1 |
Enable Orange Cloud (Proxy) |
🚨 Tips for Avoiding Pitfalls: Cloud iconMust be displayed in orange(Proxy is enabled). If this option is grayed out, it means the proxy is not enabled, and the 301 redirect feature will not work properly.
Once you've finished adding the information, click "Continue to the Next Step."
Step 3: Change the DNS servers with your domain registrar
Go to the platform where you purchased your domain (such as Alibaba Cloud, Tencent Cloud, GoDaddy, etc.) and locate the domain's DNS Management Page:
- Delete the current default DNS server addresses.
- Replace them with the following two sets of addresses assigned to you by Cloudflare (these are examples; please use the addresses displayed in your Cloudflare dashboard):
isla.ns.cloudflare.comlloyd.ns.cloudflare.com
Save your changes and wait for the DNS changes to take effect worldwide.
📌 Example (Alibaba Cloud): Domains & Websites → Domain List → Click the corresponding domain → DNS Management → Change DNS Servers.
Step 4: Create a 301 Redirect Rule
- Return to the Cloudflare dashboard and click the menu Rules(Rules) → Overview(Overview) →Create rule(Create Rule) → Then click Redirect Rules(Redirect Rules)
- Give the rule any name you like (for example, “301 Redirect”).
- Match Criteria Select Custom filter expression(Custom filter expression).

Two transition effects—please choose the one that best suits your needs.Choose one of the two, Do not set both at the same time
👉 Option 1: Redirect to the home page only (recommended for beginners)
Effect: Only when accessing the domain's homepage (i.e., the root path) /) the page will redirect; when accessing other subpages, the page loads normally and does not redirect.
Steps for Configuring the Graphical User Interface:
- Add Condition ①:Hostname equals
Your Domain Name(withoutwww, for exampleexample.com) - Click Or Additional Condition ②:Hostname equals
Your Domain Name(withwww, for examplewww.example.com) - Add another condition ③:URI Path equals
/
👉 Option 2: Redirect all pages
Effect: Whether you visit the homepage or any subpage, you will be automatically redirected to the target URL.
Steps for Configuring the Graphical User Interface:
- Add Condition ①:Hostname equals
Your Domain Name(withoutwww) - Click Or Additional Condition ②:Hostname equals
Your Domain Name(withwww)
💡 Note: Regular users are advised to simply check the boxes in the graphical interface shown above; advanced users can also click “Edit Expression” to write code directly.
Set Redirect Behavior (The following settings apply to both options)

- URL Type: Select Static(Static) — ❌ Don'tSelect "Dynamic"
A simple explanation: "Static" means that all requests are redirected toThe same oneA static URL (the one you enter below); a dynamic URL means that the destination address is automatically generated based on different requests. Regular users don't need this feature—selecting "static" is sufficient. - Destination Address (URL): Enter the full URL you want to navigate to, for example
https://www.meowtool.com/miaonav - Status Code: Select 301 - Permanent Redirect(Permanent Redirect)
- Preserve query string:Close(i.e., without the original URL parameters)
- Rule Priority (Place at): First(If “First” is selected for the redirect rule, this rule will be executed first; if “Last” is selected, it will be placed at the end of all existing rules and executed last.)
Once all settings are complete, click Save(Save). Once the DNS changes take effect, you can test whether the site is accessible.
Frequently Asked Questions (FAQ)
1.按教程操作后访问域名没有跳转,是什么原因?
最可能的原因是 DNS 尚未全球生效(最长需 48 小时)。请先确认:域名服务商处的 DNS 是否已成功修改为 Cloudflare 分配的两组地址;Cloudflare 后台域名状态是否为 Active;两条 A 记录的云朵图标是否均为橙色。如以上均确认,建议等待 1~2 小时后再测试,不要频繁反复修改。
2.两条 A 记录里的 192.0.2.1 需要换成我自己的服务器 IP 吗?
不需要。 该 IP 仅为示例虚拟地址,开启橙色代理后 Cloudflare 会接管流量,实际回源 IP 由 Cloudflare 决定。请保持原样即可。
3.方案 1(仅跳转首页)和方案 2(全部跳转)可以同时启用吗?
不可以。 两者互斥,同时设置会导致规则冲突或跳转行为异常。请根据实际需求只选择其中一种配置。
4.跳转规则保存后多久生效?
规则在 Cloudflare 端即时生效,但最终访问效果受 DNS 解析进度影响。DNS 完全生效后(通常几十分钟到 24 小时),跳转立即工作。生效前请勿反复开关规则或修改 DNS。
5.我想临时关闭跳转,该怎么做?
回到 Cloudflare 后台 Rules → Overview,找到创建的跳转规则,将开关设为 Disable(关闭),或直接删除该规则。关闭后原域名恢复正常访问(无跳转行为)。
6.域名在 Cloudflare 购买的,还需要修改 DNS 服务器吗?
不需要。 Cloudflare 注册的域名 DNS 默认由 Cloudflare 管理,直接跳过教程第 3 步,从第 4 步开始配置跳转规则即可。





