Cloudflare Tutorial: Setting Up a 301 Permanent Redirect for a Domain Name

💡 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

  1. 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).
  2. Enter your own domain name and click "Continue."
  3. Select Free(Free) Plan—after confirmation, proceed to the next step.

Add a Domain to Cloudflare

 

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:

  1. Delete the current default DNS server addresses.
  2. 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.com
    • lloyd.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.

Changing the DNS Servers of Your Domain Name Provider on Alibaba Cloud

 

Step 4: Create a 301 Redirect Rule

  1. Return to the Cloudflare dashboard and click the menu Rules(Rules) → Overview(Overview) →Create rule(Create Rule) → Then click Redirect Rules(Redirect Rules)
  2. Give the rule any name you like (for example, “301 Redirect”).
  3. Match Criteria Select Custom filter expression(Custom filter expression).

Create a 301 Redirect Rule

 

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

There are two transition effects; please choose one based on your needs—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

  1. Add Condition ①:Hostname equals Your Domain Name(without www, for example example.com
  2. Click Or Additional Condition ②:Hostname equals Your Domain Name(with www, for example www.example.com
  3. 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

  1. Add Condition ①:Hostname equals Your Domain Name(without www
  2. Click Or Additional Condition ②:Hostname equals Your Domain Name(with www

💡 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)

Set Redirect Behavior

  • 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 stringClose(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.

 

Previous Article A 300-DVD Set of Chinese Games That Brings Back Memories
August 2026
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
Loading...
List of Articles
1 Image Data Eraser
Image Data Eraser
2
What Is Success? Perhaps We Need to Live in the Moment
What Is Success? Perhaps We Need to Live in the Moment
3
A 300-DVD Set of Chinese Games That Brings Back Memories
A 300-DVD Set of Chinese Games That Brings Back Memories
4
Some Thoughts on My Anxiety During a Trip Back Home for the Dragon Boat Festival
Some Thoughts on My Anxiety During a Trip Back Home for the Dragon Boat Festival
5
Thoughts on Reading
Thoughts on Reading