How to Set Up Cloudflare Page Rules for Domain Redirection

Introduction

Redirecting traffic from one domain to another is a common need for many website owners. Perhaps you've rebranded, moved to a new domain, or simply want to direct traffic from a subdomain to a specific page. Whatever the reason, Cloudflare's Page Rules make this process simple and efficient. In this blog post, I'll walk you through how to set up a Page Rule to redirect a domain to another URL using Cloudflare, using example domains and URLs.

Step 1: Log Into Cloudflare

Start by logging into your Cloudflare account. Select the domain you want to work with from your list of domains. For our example, let's say we're working with exampledomain.com.

Step 2: Access Page Rules

Navigate to the "Page Rules" section of your Cloudflare dashboard. This is where you'll manage and create new rules for your domain.

Step 3: Create a New Page Rule

Click on "Create Page Rule." Here, you'll define the conditions and actions of your redirect.

Step 4: Define the URL to Redirect From

In the "If the URL matches" field, enter the URL or pattern you want to redirect. For example, to redirect from a subdomain, you might enter http://subdomain.exampledomain.com/*. The asterisk (*) acts as a wildcard, capturing all paths on this subdomain.

Step 5: Choose Your Forwarding URL Setting

Under "Then the settings are:" dropdown, select "Forwarding URL."

Step 6: Set Up Your Destination URL

Next, you'll choose the type of redirect:

  • 301 - Permanent Redirect: Use this if the change is permanent. It tells search engines that the page has moved permanently.
  • 302 - Temporary Redirect: Use this for temporary changes.

In the "Destination URL" field, enter the URL you want to redirect to. For our example, let's redirect to http://newdomain.com/special-page.

Step 7: Save and Deploy

Once you've set up your rule, click "Save and Deploy." The redirect should start working almost immediately, but it might take a few minutes to propagate fully.

Step 8: Testing

After the rule is active, test it by visiting the old URL. It should seamlessly redirect to the new URL you specified.

Conclusion

Using Cloudflare's Page Rules for redirection is a powerful way to manage your web traffic and ensure users are directed to the right place. Whether consolidating domains or guiding users to new content, these rules are an invaluable tool in your web administration toolkit.

Remember, while redirects are helpful, they should be used judiciously to maintain the integrity of your site structure and search engine ranking. Happy redirecting!