💡 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.。
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. I followed the tutorial, but when I visit the domain, it doesn't redirect. What could be the reason?
The most likely reason is The DNS update has not yet taken effect globally.(This may take up to 48 hours.) Please first verify: whether the DNS settings at your domain registrar have been successfully updated to the two sets of IP addresses assigned by Cloudflare; and whether the domain status in the Cloudflare dashboard is Active; Are the cloud icons for the two A recordsAll are orange. If all of the above are confirmed, we recommend waiting 1 to 2 hours before retesting,Don't make frequent, repeated changes.。
2. Do I need to replace "192.0.2.1" in the two A records with my own server's IP address?
No, that's not necessary. This IP address is only an example of a virtual address. Once the Orange Proxy is enabled, Cloudflare will take over the traffic, and the actual origin IP address will be determined by Cloudflare. PleaseLeave it as isThat's it.
3. Can Option 1 (redirect only to the homepage) and Option 2 (redirect all) be enabled at the same time?
No. These two options are mutually exclusive; setting both at the same time will result in rule conflicts or abnormal redirect behavior. Please choose based on your actual needs.Choose only one of themConfiguration.
4. How long does it take for the redirect rules to take effect after they are saved?
Rules on the Cloudflare sideEffective immediately, but the final results of the visit depend on DNS Resolution ProgressImpact: Once the DNS changes take full effect (typically within a few tens of minutes to 24 hours), the redirect will work immediately. Please do not repeatedly enable or disable the rule or modify the DNS settings before the changes take effect.
5. I want to temporarily disable the redirect. How do I do that?
Return to the Cloudflare dashboard Rules → Overview, locate the redirect rule you created, and set the toggle to Disable (Turn Off), or simply delete the rule. Once disabled, the original domain will resume normal access (without any redirects).
6. If I purchased the domain through Cloudflare, do I still need to change the DNS servers?
No, that's not necessary. DNS for domains registered with Cloudflare is managed by Cloudflare by default, and you can directlySkip Step 3 of the tutorial... Simply start configuring the redirection rules from Step 4.





