Skip to content

Redirects

A redirect sends visitors from one URL to another URL with an HTTP status code, such as 301. Redirects are also known as URL forwarding. Single Redirects and Bulk Redirects replace the Forwarding URL setting in Page Rules.

In the Cloudflare dashboard, Single Redirects appear as Redirect Rules.

Choose a redirect product

Use the following table to choose a redirect product for your use case:

Goal Product Refer to
Move a whole domain or subdomain to a new hostname, keeping the path Single Redirects Redirect requests to a different hostname
Send every page of an old domain to the homepage of a new domain Single Redirects Redirect requests for a domain to a new domain
Redirect one page to another page Single Redirects Redirect visitors to a new page URL
Redirect a section of a website, such as /blog/* to blog.example.com/* Single Redirects Redirect a website section to a subdomain
Redirect all HTTP requests to HTTPS Always Use HTTPS (recommended) Always Use HTTPS
Redirect HTTP to HTTPS for some hostnames or paths only Single Redirects Redirect admin area requests to HTTPS
Redirect www to the root domain, or the root domain to www Single Redirects Redirect from WWW to root, Redirect from root to WWW
Redirect visitors based on country Single Redirects Redirect local visitors to specific subdomains, Redirect visitors from one country to a subdomain
Redirect visitors based on device, such as mobile phones Single Redirects Perform mobile redirects
Redirect using regular expressions (Business and Enterprise plans) Single Redirects Remove locale from URL path, Single Redirects availability
Replace a Page Rule that uses the Forwarding URL setting Single Redirects Migrate Forwarding URL
Redirect a list of specific URLs, such as old and new URLs from a migration Bulk Redirects Create Bulk Redirects in the dashboard
Redirect the same path prefix on several domains (one URL redirect per hostname) Bulk Redirects Subpath matching, CSV file format
Redirect with custom logic that rules cannot express (Pro plan and above) Snippets Bulk redirect based on a map object, Country code redirect

To create a redirect, refer to Create a redirect rule in the dashboard or Create Bulk Redirects in the dashboard.

Redirect products

  • Single Redirects: Static or dynamic redirects for one zone (a domain you added to Cloudflare, including its subdomains). With a wildcard pattern, one rule can cover thousands of URLs without functions or regular expressions. You can also match requests by country, device, header, or cookie with a custom filter expression.

  • Bulk Redirects: Lists of source and target URLs at the account level, which can apply across domains in your account. Each URL redirect maps one source URL to one target URL. Bulk Redirects do not support wildcards or regular expressions, but URL redirect parameters, such as Subpath matching and Include subdomains, control how source URLs match.

  • Snippets: Short pieces of JavaScript code for complex redirect logic. Refer to the Snippets examples to get started.

Redirect Rules templates

Cloudflare provides you with rules templates for common use cases.

  1. In the Cloudflare dashboard, go to the Rules Overview page.

    Go to Overview ↗
  2. Select Templates, and then select one of the available templates.

You can also refer to the Examples gallery in the developer docs.

Redirect templates include Redirect from HTTP to HTTPS, Redirect from WWW to root, and Redirect from root to WWW. The Redirect from HTTP to HTTPS template uses the request URL http://* and the target URL https://${1}.

The Redirect from WWW to root and Redirect from root to WWW templates match HTTPS requests only. To also redirect HTTP requests, turn on Always Use HTTPS, or change the request URL to start with http*:// and update the wildcard references in the target URL. Refer to How wildcard references are numbered.

Availability

Single Redirects and Bulk Redirects are available on all Cloudflare plans. The exact quotas and features depend on your plan.

Bulk Redirects

Free Pro Business Enterprise
Availability Yes Yes Yes Yes
Bulk Redirect Rules 15 15 15 50
Bulk Redirect Lists 5 5 5 25
URL redirects across lists 10,000 25,000 50,000 1,000,000

For URL redirects across lists, this table provides the default quota for the Enterprise plan. Bulk Redirects supports several million URL redirects — to get more redirects, contact your account team.

Bulk Redirects features and quotas are per account and they depend on the highest Cloudflare plan on your account.

Single Redirects

Free Pro Business Enterprise
Availability Yes Yes Yes Yes
Number of rules 10 25 50 300
Wildcard support Yes Yes Yes Yes
Regex support No No Yes Yes

Single Redirects features and quotas are per zone and depend on the zone plan.

Execution order

The execution order of Rules features is the following:

The different types of rules listed above will take precedence over Page Rules. This means that Page Rules will be overridden if there is a match for both Page Rules and the Rules products listed above.

Generally speaking, for non-terminating actions the last change made by rules in the same phase will win (later rules can overwrite changes done by previous rules). However, for terminating actions (Block, Redirect, or one of the challenge actions), rule evaluation will stop and the action will be executed immediately.

For example, if multiple rules with the Redirect action match, Cloudflare will always use the URL redirect of the first rule that matches. Also, if you configure URL redirects using different Cloudflare products (Single Redirects and Bulk Redirects), the product executed first will apply, if there is a rule match (in this case, Single Redirects).

Refer to the Phases list for the product execution order.

Troubleshooting

When troubleshooting URL redirects, use Rules simulator to determine if a rule is triggering for a specific URL.

Was this helpful?