Page Rules & Redirects
Cloudflare Page Rules let you apply specific settings to URLs that match a pattern. They are commonly used for redirects, HTTPS enforcement, and cache control. The free Cloudflare plan includes 3 page rules per domain.
What Are Page Rules?
Page Rules trigger specific Cloudflare behaviors when a request matches a URL pattern you define. The pattern uses simple wildcard matching where * matches any sequence of characters. For example:
yourdomain.com/*— matches all pages on your domain.*.yourdomain.com/*— matches all pages on all subdomains.yourdomain.com/wp-admin/*— matches only your WordPress admin area.
When a request matches a pattern, Cloudflare applies the settings you configured for that rule. If multiple rules match, only the rule with the highest priority (lowest order number) applies.
Common Page Rules
Always Use HTTPS
This rule redirects all HTTP requests to HTTPS. It is one of the most commonly used page rules.
- In your Cloudflare dashboard, go to Rules → Page Rules.
- Click Create Page Rule.
- Enter the URL pattern:
http://yourdomain.com/* - Select the setting: Always Use HTTPS.
- Click Save and Deploy.
Repeat with http://www.yourdomain.com/* if you also use the www version. Alternatively, you can enable Always Use HTTPS globally under SSL/TLS → Edge Certificates without using a page rule.
Forwarding URL (Redirects)
The Forwarding URL setting lets you redirect visitors from one URL to another. You can choose between a 301 (Permanent) or 302 (Temporary) redirect.
- 301 Permanent Redirect: Tells browsers and search engines the page has moved permanently. Search engines transfer ranking to the new URL. Use this for domain migrations and permanent changes.
- 302 Temporary Redirect: Tells browsers the redirect is temporary. Search engines keep the original URL indexed. Use this for maintenance or A/B testing.
Cache Level Bypass
This rule tells Cloudflare to skip caching entirely for matched URLs. This is useful for admin areas and other dynamic pages where you always want fresh content from the server.
Example: Redirect www to non-www
To redirect all traffic from www.yourdomain.com to yourdomain.com:
- Go to Rules → Page Rules and click Create Page Rule.
- Enter the URL pattern:
www.yourdomain.com/* - Select Forwarding URL with a 301 - Permanent Redirect.
- Set the destination URL to:
https://yourdomain.com/$1 - Click Save and Deploy.
The $1 captures whatever matched the * wildcard and appends it to the destination URL. So www.yourdomain.com/about redirects to yourdomain.com/about.
To do the reverse (non-www to www), swap the pattern and destination:
- Pattern:
yourdomain.com/* - Destination:
https://www.yourdomain.com/$1
Example: Redirect Old Domain to New Domain
If you have moved your website from old-domain.com to new-domain.com, you can use Cloudflare to redirect all traffic. Both domains must be added to your Cloudflare account.
- Add
old-domain.comto Cloudflare and point its nameservers to Cloudflare. - Go to Rules → Page Rules for
old-domain.com. - Create a page rule with the pattern:
old-domain.com/* - Select Forwarding URL with a 301 - Permanent Redirect.
- Set the destination URL to:
https://new-domain.com/$1 - Click Save and Deploy.
This preserves the URL path, so old-domain.com/contact redirects to new-domain.com/contact.
Example: Bypass Cache for WordPress Admin
To ensure the WordPress admin area is never cached (preventing potential issues with stale admin pages):
- Create a page rule with the pattern:
yourdomain.com/wp-admin/* - Set Cache Level to Bypass.
- Optionally, also disable Rocket Loader and Auto Minify for the admin area to avoid script conflicts.
- Click Save and Deploy.
/wp-admin/* and /wp-login.php, you can use the pattern yourdomain.com/wp-* to cover both with a single rule.
Bulk Redirects
Cloudflare's Bulk Redirects feature is a newer alternative to page rules for handling redirects. It allows you to create lists of URL redirects without using page rules, which is useful when you need more than 3 redirects on the free plan.
- In your Cloudflare dashboard, go to Rules → Bulk Redirects.
- Click Create Bulk Redirect List.
- Add your source and destination URLs to the list.
- Create a Bulk Redirect Rule that references your list.
- Deploy the rule.
Bulk Redirects are ideal when you are migrating a site and need to redirect dozens or hundreds of individual URLs. They do not count against your page rule limit.
Page Rules vs .htaccess Redirects
Both Cloudflare Page Rules and .htaccess rules can handle redirects, but they work at different levels:
- Cloudflare Page Rules execute at Cloudflare's edge servers before the request ever reaches your hosting server. The redirect happens faster because it does not need to travel to your server and back. There is zero load on your hosting account.
- .htaccess redirects execute on your Ultra Web Hosting server after the request arrives. They are more flexible (support regex, conditions, and complex rewrite logic) and do not count against a page rule limit.
When to use Cloudflare redirects:
- Simple domain-level or www redirects.
- Redirecting an old domain to a new one (the old domain does not even need hosting).
- When you want the fastest possible redirect with no server load.
When to use .htaccess redirects:
- Complex redirect rules with conditions (e.g., redirect based on user agent, query parameters, or cookies).
- When you need more than 3 redirect rules and do not want to use Bulk Redirects.
- When you are not using Cloudflare or want your redirects to work regardless of Cloudflare status.