{"id":81776,"date":"2023-03-24T16:40:59","date_gmt":"2023-03-24T16:40:59","guid":{"rendered":"\/tutorials\/?p=81776"},"modified":"2026-03-10T09:28:31","modified_gmt":"2026-03-10T09:28:31","slug":"cloudflare-page-rules","status":"publish","type":"post","link":"\/ca\/tutorials\/cloudflare-page-rules","title":{"rendered":"Most common Cloudflare page rules: How to create and edit"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Using Cloudflare Page Rules is a great option for those looking to optimize their websites. It is a beginner-friendly method, as it is unnecessary to modify any code to enable it &ndash; Cloudflare dashboard has an easy-to-use menu for managing all settings.<\/p><p>Page rules are available on all Cloudflare plans and can be used for setting up cache rules, forwarding URLs, and more. In this article, we will discuss the importance of these rules and how to set them up. On top of that, we will explain the 13 most common page rules.<\/p><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/How-to-Speed-Up-Your-Website-EN.pdf\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website-1024x283.png\" alt=\"\" class=\"wp-image-69260\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-why-page-rules-are-important\">Why Page Rules Are Important<\/h2><p>Page rules trigger certain actions whenever a request matches one of the defined domain patterns. They let you customize Cloudflare settings and values for all or specific web pages. Additionally, they help improve the <a href=\"\/ca\/tutorials\/website-performance\">site&rsquo;s performance<\/a>, security, reliability, and user experience.<\/p><p>Cloudflare rules have two basic behaviors:<\/p><ul class=\"wp-block-list\">\n<li>Only the highest priority matching rule works on a request.<\/li>\n\n\n\n<li>Cloudflare prioritizes the settings in descending order, from the highest priority rule to the lowest.<\/li>\n<\/ul><p>A page rule matches a URL pattern based on five segments:<\/p><ul class=\"wp-block-list\">\n<li><strong>Scheme.<\/strong> Indicates the communication protocol used.<\/li>\n\n\n\n<li><strong>Hostname.<\/strong> Specifies the domain name.<\/li>\n\n\n\n<li><strong>Port.<\/strong> Indicates the protocol&rsquo;s port.<\/li>\n\n\n\n<li><strong>Path.<\/strong> Specifies the file or directory path.<\/li>\n\n\n\n<li><strong>Query string<\/strong>. A set of parameters attached to the end of the URL to assign values to certain attributes.<\/li>\n<\/ul><p>The resulting format will look like this:<\/p><pre class=\"wp-block-preformatted\">&lt;scheme&gt;:\/\/&lt;hostname&gt;&lt;:port&gt;\/&lt;path&gt;?&lt;query_string&gt;<\/pre><p>However, the scheme and port elements are optional. If omitted, the scheme matches both HTTPS and HTTP protocols. On the other hand, if the port is not specified, the page rule matches all ports.<\/p><p>When creating a page rule, use an asterisk (<strong>*<\/strong>) in any URL segment to indicate a <a href=\"https:\/\/developers.cloudflare.com\/cache\/reference\/wildcard-matching\/\" target=\"_blank\" rel=\"noopener\">wildcard for matching<\/a> specific patterns. For example:<\/p><pre class=\"wp-block-preformatted\">https:\/\/example.com\/image*<\/pre><h2 class=\"wp-block-heading\" id=\"h-how-to-set-up-cloudflare-page-rules\">How to Set Up Cloudflare Page Rules<\/h2><p>The following sections will show you how to set up Cloudflare Page Rules.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Learn More About Cloudflare<\/h4>\n                    <p><a href=\"\/ca\/tutorials\/what-is-cdn\">What Is a CDN?<\/a><br>\n<a href=\"\/ca\/tutorials\/improving-website-performance-using-a-cdn\">How to Set Up a CDN: Tips to Improve Website Performance<\/a><br>\n<a href=\"\/ca\/tutorials\/how-to-setup-cloudflare-for-wordpress\">How to Set Up Cloudflare CDN on WordPress<\/a><\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-create-a-page-rule-in-cloudflare\">How to Create a Page Rule in Cloudflare<\/h3><p>Here&rsquo;s how to create a rule in Cloudflare:<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>Ensure to list the page rules from the most to the least specific.<\/p>\n                <\/div>\n\n\n\n<\/p><ol class=\"wp-block-list\">\n<li>Log in to your <strong>Cloudflare dashboard<\/strong> and choose a domain.<\/li>\n<\/ol><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Home-page-on-Cloudflare-with-a-domain-highlighted.png\"><img loading=\"lazy\" decoding=\"async\" width=\"743\" height=\"296\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Home-page-on-Cloudflare-with-a-domain-highlighted.png\" alt=\"The Home page on Cloudflare with a domain highlighted\n\" class=\"wp-image-82652\"  sizes=\"auto, (max-width: 743px) 100vw, 743px\" \/><\/a><\/figure><ol start=\"2\" class=\"wp-block-list\">\n<li>Select the <strong>Rules<\/strong> menu.<\/li>\n<\/ol><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-domain-dashboard-on-Cloudflare-highlighting-the-Rules-menu-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"640\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-domain-dashboard-on-Cloudflare-highlighting-the-Rules-menu-1.png\" alt=\"The domain dashboard on Cloudflare, highlighting the Rules menu\n\" class=\"wp-image-82653\"  sizes=\"auto, (max-width: 258px) 100vw, 258px\" \/><\/a><\/figure><ol start=\"3\" class=\"wp-block-list\">\n<li>Click <strong>Create Page Rule<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rules-tab-on-Cloudflare-with-the-Create-Page-Rule-button-highlighted.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"379\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rules-tab-on-Cloudflare-with-the-Create-Page-Rule-button-highlighted-1024x379.png\" alt=\"The Page Rules tab on Cloudflare with the Create Page Rule button highlighted\" class=\"wp-image-82655\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>On the <strong>If the URL matches<\/strong> tab, insert the URL or URL pattern that should match the page rule.<\/li>\n<\/ol><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Create-a-Page-Rule-tab-on-Cloudflare.png\"><img loading=\"lazy\" decoding=\"async\" width=\"774\" height=\"329\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Create-a-Page-Rule-tab-on-Cloudflare.png\" alt=\"The Create a Page Rule tab on Cloudflare\n\" class=\"wp-image-82656\"  sizes=\"auto, (max-width: 774px) 100vw, 774px\" \/><\/a><\/figure><ol start=\"5\" class=\"wp-block-list\">\n<li>Under <strong>Then the settings are<\/strong> tab, pick an option and choose <strong>the status code<\/strong> by selecting the down arrows in each box. In this example, we&rsquo;re using <strong>Forwarding URL<\/strong> and <strong>301 &ndash; Permanent Redirect<\/strong>.<\/li>\n<\/ol><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Pick-a-Setting-and-Select-status-code-sections-on-Cloudflare_s-Page-Rule-menu.png\"><img loading=\"lazy\" decoding=\"async\" width=\"606\" height=\"120\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Pick-a-Setting-and-Select-status-code-sections-on-Cloudflare_s-Page-Rule-menu.png\" alt=\"The Pick a Setting and Select status code sections on Cloudflare's Page Rule menu\n\" class=\"wp-image-82657\"  sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/a><\/figure><ol start=\"6\" class=\"wp-block-list\">\n<li>Type <strong>the destination URL<\/strong>.<\/li>\n<\/ol><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Enter-destination-URL-section.png\"><img loading=\"lazy\" decoding=\"async\" width=\"776\" height=\"84\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Enter-destination-URL-section.png\" alt=\"The Enter destination URL section\n\" class=\"wp-image-82658\"  sizes=\"auto, (max-width: 776px) 100vw, 776px\" \/><\/a><\/figure><ol start=\"7\" class=\"wp-block-list\">\n<li>Save the changes. For this example, we&rsquo;re choosing the second option.<\/li>\n<\/ol><ul class=\"wp-block-list\">\n<li><strong>Save as Draft <\/strong>to save the settings.<\/li>\n\n\n\n<li><strong>Save and Deploy Page Rule<\/strong> to save and apply it immediately.<\/li>\n<\/ul><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-save-options-on-Cloudflare_s-Page-Rule-menu-highlighting-the-Save-and-Deploy-Page-Rule-button.png\"><img loading=\"lazy\" decoding=\"async\" width=\"431\" height=\"56\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-save-options-on-Cloudflare_s-Page-Rule-menu-highlighting-the-Save-and-Deploy-Page-Rule-button.png\" alt=\"The save options on Cloudflare's Page Rule menu, highlighting the Save and Deploy Page Rule button\n\" class=\"wp-image-82659\"  sizes=\"auto, (max-width: 431px) 100vw, 431px\" \/><\/a><\/figure><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>Cloudflare doesn't accept non-ASCII characters in Page Rules. Try to URL-encode the string using a Punycode converter.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-edit-cloudflare-page-rules\">How to Edit Cloudflare Page Rules<\/h3><p>Follow these instructions to edit a page rule in Cloudflare:<\/p><ol class=\"wp-block-list\">\n<li>Choose the page rule that you want to edit.<\/li>\n<\/ol><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rules-tab-on-Cloudflare-highlighting-the-domain.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1006\" height=\"508\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rules-tab-on-Cloudflare-highlighting-the-domain.png\" alt=\"The Page Rules tab on Cloudflare, highlighting the domain\n\" class=\"wp-image-82660\"  sizes=\"auto, (max-width: 1006px) 100vw, 1006px\" \/><\/a><\/figure><ol start=\"2\" class=\"wp-block-list\">\n<li>To enable or disable it, toggle the <strong>On<\/strong> and <strong>Off<\/strong> buttons.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rules-on-Cloudflare-with-the-on-and-off-button-highlighted-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"977\" height=\"58\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rules-on-Cloudflare-with-the-on-and-off-button-highlighted-1.png\" alt=\"The Page Rules on Cloudflare with the on and off button highlighted\" class=\"wp-image-82661\"  sizes=\"auto, (max-width: 977px) 100vw, 977px\" \/><\/a><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Select the <strong>Edit<\/strong> button to change the URL or URL pattern, settings, and order.<\/li>\n<\/ol><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rule-on-Cloudflare-highlighting-the-Edit-button.png\"><img loading=\"lazy\" decoding=\"async\" width=\"977\" height=\"56\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rule-on-Cloudflare-highlighting-the-Edit-button.png\" alt=\"The Page Rule on Cloudflare, highlighting the Edit button\n\" class=\"wp-image-82662\"  sizes=\"auto, (max-width: 977px) 100vw, 977px\" \/><\/a><\/figure><ol start=\"4\" class=\"wp-block-list\">\n<li>To delete a rule, click the <strong>Delete<\/strong> button and choose <strong>Delete<\/strong> on the pop-up window.<\/li>\n<\/ol><figure class=\"wp-block-image aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rule-on-Cloudflare-with-the-Delete-button-highlighted.png\"><img loading=\"lazy\" decoding=\"async\" width=\"977\" height=\"55\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/The-Page-Rule-on-Cloudflare-with-the-Delete-button-highlighted.png\" alt=\"The Page Rule on Cloudflare with the Delete button highlighted\n\" class=\"wp-image-82663\"  sizes=\"auto, (max-width: 977px) 100vw, 977px\" \/><\/a><\/figure><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>When a page rule is disabled, it won't trigger actions, but it will still appear in the Page Rules tab. The rule is editable and counts towards the number of rules allowed for the domain.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-common-cloudflare-page-rules-to-consider\">Common Cloudflare Page Rules to Consider<\/h2><p>There are hundreds of rules you can create for your website, but here are the 13 essential ones.<\/p><h3 class=\"wp-block-heading\" id=\"h-301-302-forward-url\">301\/302 Forward URL<\/h3><p>Use the <strong>Forwarding URL<\/strong> setting to direct visitors to a specific page or define the root as your domain&rsquo;s canonical version. You can choose either the HTTP 301 Permanent Redirect or HTTP 302 Temporary Redirect. The asterisk (<strong>*<\/strong>) creates dynamic patterns that ensure every variation will be redirected to the destination URL.<\/p><p>In addition, reference a matched wildcard using the <strong>$X syntax<\/strong>, where <strong>X<\/strong> means the index of a <a href=\"https:\/\/gulpjs.com\/docs\/en\/getting-started\/explaining-globs\/\" target=\"_blank\" rel=\"noopener\">glob pattern<\/a>. Hence, <strong>$1<\/strong> refers to the first wildcard match, and so on.<\/p><p>For example, to redirect visitors from a specific page to the root domain, enter these settings:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>*www.example.com\/home<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Forwarding URL<\/strong><\/li>\n\n\n\n<li>Select status code: <strong>301 Permanent Redirect<\/strong><\/li>\n\n\n\n<li>Enter destination URL: <strong>https:\/\/www.example.com\/<\/strong><\/li>\n<\/ul><p>On the other hand, to redirect visitors to a specific web page, use the following settings:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>*www.example.com\/tw*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Forwarding URL<\/strong><\/li>\n\n\n\n<li>Select status code: <strong>302 Temporary Redirect<\/strong><\/li>\n\n\n\n<li>Enter destination URL: <strong>https:\/\/www.twitter.com\/username<\/strong><\/li>\n<\/ul><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>Avoid redirecting your domain to itself as the destination, as it can cause an infinite redirect error.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-forward-to-www\">Forward to &ldquo;WWW&rdquo;<\/h3><p>Choose URL forwarding to redirect a domain&rsquo;s pages and subdomains to www. For instance:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Forwarding URL<\/strong><\/li>\n\n\n\n<li>Select status code: <strong>301 Permanent Redirect<\/strong><\/li>\n\n\n\n<li>Enter destination URL: <strong>https:\/\/www.example.com\/$1<\/strong><\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-always-use-https\">Always Use HTTPS<\/h3><p>This page rule forces visitors to use an HTTPS connection when visiting the website. Adding * to the URL ensures that Cloudflare will redirect all access made via HTTP to HTTPS.<\/p><p>To create the page rule, use the following setup:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>http:\/\/*example.com\/*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Always Use HTTPS<\/strong><\/li>\n<\/ul><p>If your website doesn&rsquo;t have SSL installed, enable the Cloudflare <strong>Opportunistic Encryption<\/strong> feature. With it, visitors can access the site over an encrypted TLS channel. However, keep in mind this setting can&rsquo;t replace SSL.<\/p><p>Add the following rule and turn it on:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>http:\/\/*example.com\/*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Opportunistic Encryption<\/strong><\/li>\n<\/ul><p>If you are a Hostinger user, note that all our <a href=\"\/ca\/web-hosting\">hosting plans<\/a> include unlimited SSL certificates.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-full\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-web-hosting\" href=\"\/ca\/web-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-security-level-amp-cache-level\">Security Level &amp; Cache Level<\/h3><p>Some website pages, such as the user or admin dashboard, have different performance and security requirements than public sections. Using a page rule, you can adjust protection and cache configurations, especially for requests targeting specific paths.<\/p><p>To use the <strong>Security Level<\/strong> &amp; <strong>Cache Level<\/strong> settings, enter:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/client-page*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Security Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>High<\/strong><\/li>\n<\/ul><p>Depending on the <a href=\"https:\/\/support.cloudflare.com\/hc\/en-us\/articles\/200170056-Understanding-the-Cloudflare-Security-Level\" target=\"_blank\" rel=\"noopener\">threat score<\/a>, visitors will encounter a challenge page requiring them to click the <strong>I&rsquo;m not a robot<\/strong> box.<\/p><p>Enabling <strong>Origin Cache Control<\/strong>, Cloudflare will examine whether the file is cacheable. To do this, add another option to the same page rule and turn it on:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Origin Cache Control<\/strong><\/li>\n<\/ul><p>Alternatively, instruct Cloudflare to bypass cache using the <strong>Cache Level<\/strong> setting:<\/p><ul class=\"wp-block-list\">\n<li>Setting:<strong> Cache Level<\/strong><\/li>\n\n\n\n<li>Value:<strong> Bypass<\/strong><\/li>\n<\/ul><p>Disabling active Cloudflare apps and performance tools prevents software conflicts within the admin page. Insert the following rule and turn it on:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Disable Apps<\/strong><\/li>\n<\/ul><p>Disallow Cloudflare features like Auto Minify, Rocket Loader, Mirage, and Polish by activating this setting:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Disable Performance<\/strong><\/li>\n<\/ul><p>Instruct Cloudflare to scan the visitor&rsquo;s browser for HTTP headers commonly associated with bots and spammers by turning on this option:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Browser Integrity Check<\/strong><\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-edge-cache-ttl-and-browser-cache-ttl\">Edge Cache TTL and Browser Cache TTL<\/h3><p>Since some resources on your site don&rsquo;t change constantly, enabling custom caching options can reduce the load and bandwidth usage for the origin server. It also overrides the default cache behavior for static files.<\/p><p>Set up a <strong>Browser Cache TTL<\/strong> rule to control how long the cache remains valid. In this example, we target the media folder and set the value to <strong>a day<\/strong>:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/sites\/content\/media<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Browser Cache TTL<\/strong><\/li>\n\n\n\n<li>Value: <strong>a day<\/strong><\/li>\n<\/ul><p>As for <strong>Cache Level<\/strong>, apply the <strong>Cache Everything<\/strong> option to consider all content as static and store all file types. Unless <strong>Edge Cache TTL<\/strong> is enabled, it also respects cache headers from the origin server. When you combine both, Cloudflare deletes cookies from the origin web server response.<\/p><p>To enable it, add the following setting to the same page rule:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Cache Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>Cache Everything<\/strong><\/li>\n<\/ul><p><strong>Edge Cache TTL<\/strong> refers to the cache duration in the Cloudflare edge network. This rule is invisible in the response headers. However, the minimum <strong>Edge Cache TTL<\/strong> value depends on the Cloudflare plan. For instance, if you have a free Cloudflare account, the value options start from 2 hours.<\/p><p>For this example, we set the duration to seven days:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Edge Cache TTL<\/strong><\/li>\n\n\n\n<li>Value: <strong>7 days<\/strong><\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-cache-everything\">Cache Everything<\/h3><p>If your web pages rely on static content, set the Cloudflare <strong>Cache Level<\/strong> to <strong>Cache Everything<\/strong>. This ensures the fundamental elements, including HTML and JSON data, are cached. In this example, we will activate it for a Refund Policy page:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/refund-policy<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Cache Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>Cache Everything<\/strong><\/li>\n<\/ul><p>Cloudflare&rsquo;s Business and Enterprise customers can <a href=\"https:\/\/support.cloudflare.com\/hc\/en-us\/articles\/236166048\" target=\"_blank\" rel=\"noopener\">cache static HTML data<\/a> on their WordPress site using the <strong>Bypass Cache on Cookie<\/strong> feature.<\/p><h3 class=\"wp-block-heading\" id=\"h-secure-wordpress-log-in-area\">Secure WordPress Log In Area<\/h3><p>The login page of a WordPress site shouldn&rsquo;t be cached as it contains sensitive information. Therefore, use the following setting on your site:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/wp-admin*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Security Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>High<\/strong><\/li>\n<\/ul><p>To ensure Cloudflare doesn&rsquo;t cache the content, enter:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Cache Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>Bypass<\/strong><\/li>\n<\/ul><p>Consider using the <strong>Cache Deception Armor<\/strong> feature to protect your page from web cache deception attacks. Ensure the <strong>Edge Cache TTL<\/strong> is off to avoid overriding the cache instructions.<\/p><p>To enable this rule, add the option and toggle the button to on:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Cache Deception Armor<\/strong><\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-forward-affiliate-url\">Forward Affiliate URL<\/h3><p>With a page rule, you can cloak affiliate links using the <strong>Forwarding URL<\/strong> setting. Depending on your preference, you can either redirect it permanently or temporarily.<\/p><p>To enable it, add the following page rule:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/product-affiliate<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Forwarding URL<\/strong><\/li>\n\n\n\n<li>Status code: <strong>301 Permanent Redirect<\/strong><\/li>\n\n\n\n<li>Destination URL: <strong>https:\/\/product-affiliate.com\/a\/abc1234EFG<\/strong><\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-decrease-bandwidth-of-wp-uploads\">Decrease Bandwidth of WP Uploads<\/h3><p>In most cases, items in your <a href=\"\/ca\/tutorials\/wordpress-content-uploads\">WP-Content folder<\/a> don&rsquo;t change frequently. To save bandwidth usage, set the <strong>Edge Cache TTL<\/strong> value to <strong>a month<\/strong>. This means Cloudflare will request new content from the origin server only once a month.<\/p><p>Here&rsquo;s how to create the rule:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/wp-content\/uploads*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Edge Cache TTL<\/strong><\/li>\n\n\n\n<li>Value: <strong>a month<\/strong><\/li>\n<\/ul><p>Configuring Cloudflare&rsquo;s <strong>Cache Level<\/strong> to <strong>Cache Everything<\/strong> would look like this:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Cache Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>Cache Everything<\/strong><\/li>\n<\/ul><p>To prevent displaying old information on the site, add <strong>Browser Cache TTL<\/strong> and set the value to <strong>a day<\/strong> so the resources will expire from the visitor&rsquo;s browsers after 24 hours. To apply it, add the following rule:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Browser Cache TTL<\/strong><\/li>\n\n\n\n<li>Value: <strong>a day<\/strong><\/li>\n<\/ul><p>If you update or modify certain files or directories in less than a month, <a href=\"https:\/\/developers.cloudflare.com\/cache\/how-to\/purge-cache\/\" target=\"_blank\" rel=\"noopener\">purge Cloudflare cache<\/a>.<\/p><h3 class=\"wp-block-heading\" id=\"h-don-t-cache-preview-pages\">Don&rsquo;t Cache Preview Pages<\/h3><p>Preview pages shouldn&rsquo;t be cached as they are not on the live website. Thus, adjust the settings to bypass cache to ensure you view the correct website version:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/preview-website*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Cache Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>Bypass<\/strong><\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-forward-xml-rpc-urls\">Forward XML-RPC URLs<\/h3><p>Using the <a href=\"\/ca\/tutorials\/xmlrpc-wordpress\">WordPress XML-RPC<\/a> feature can make your site prone to security issues, such as DDoS and brute force attacks. In the first situation, attackers will use the <strong>xmlrpc.php<\/strong> file to send multiple pingbacks to your website simultaneously, causing an overload.<\/p><p>On brute force attacks, hackers will use the file to try various username and password combinations to enter your site.<\/p><p>As an additional security layer, a page rule can forward requests to the <strong>xmlrpc.php<\/strong> file to a desired destination. In this example, we&rsquo;re using the homepage URL.<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/xmlrpc.php*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Forwarding URL<\/strong><\/li>\n\n\n\n<li>Status code: <strong>301 Permanent Redirect<\/strong><\/li>\n\n\n\n<li>Destination URL: <strong>https:\/\/example.com<\/strong><\/li>\n<\/ul><p>Adding this page rule, Cloudflare CDN will stop the malicious traffic before it reaches your origin server.<\/p><h3 class=\"wp-block-heading\" id=\"h-enable-email-obfuscation-on-the-contact-page-only\">Enable Email Obfuscation on the Contact Page Only<\/h3><p>To avoid bots from adding your email address to their spam list, enable the Cloudflare <strong>Email Obfuscation<\/strong> feature for a specific page. This setting can encrypt email addresses while keeping them readable for humans.<\/p><p>To activate it, create the following page rule:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/contact-us*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Browser Cache TTL<\/strong><\/li>\n\n\n\n<li>Value: <strong>a day<\/strong><\/li>\n<\/ul><p>Allow Cloudflare to cache all elements:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Cache Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>Cache Everything<\/strong><\/li>\n<\/ul><p>Add the edge caching setting:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Edge Cache TTL<\/strong><\/li>\n\n\n\n<li>Value: <strong>a month<\/strong><\/li>\n<\/ul><p>Lastly, add the email masking option and turn it on:<\/p><ul class=\"wp-block-list\">\n<li>Setting: <strong>Email Obfuscation<\/strong><\/li>\n<\/ul><p>You can enable the <strong>Email Obfuscation<\/strong> rule on all pages using the Cloudflare <strong>Scrape Shield<\/strong> app. However, it may trigger the<strong> email-decode.min.js<\/strong> error on <a href=\"https:\/\/pagespeed.web.dev\/\" target=\"_blank\" rel=\"noopener\">PageSpeed Insights<\/a> and <a href=\"https:\/\/gtmetrix.com\/\" target=\"_blank\" rel=\"noopener\">GTmetrix<\/a>.<\/p><h3 class=\"wp-block-heading\" id=\"h-ecommerce-sites-and-dynamic-content-using-ajax\">eCommerce Sites and Dynamic Content Using AJAX<\/h3><p>eCommerce sites contain dynamic content that shouldn&rsquo;t be cached. However, you still need to cache other elements to improve the <a href=\"\/ca\/tutorials\/website-performance\">website&rsquo;s performance<\/a>.<\/p><p>Therefore, we recommend caching the static elements while bypassing AJAX cache for the dynamic content. You can implement those settings using two-page rules.<\/p><p>The first instructs Cloudflare to bypass cache for AJAX:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/ajax*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Cache Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>Bypass<\/strong><\/li>\n<\/ul><p>The second one lets Cloudflare cache other elements:<\/p><ul class=\"wp-block-list\">\n<li>If the URL matches: <strong>example.com\/*<\/strong><\/li>\n\n\n\n<li>Setting: <strong>Cache Level<\/strong><\/li>\n\n\n\n<li>Value: <strong>Cache Everything<\/strong><\/li>\n<\/ul><p>Alternatively, Cloudflare Enterprise users can utilize <a href=\"https:\/\/developers.cloudflare.com\/cache\/about\/cache-keys\" target=\"_blank\" rel=\"noopener\">Cache Keys<\/a> to control what to include when determining the cache settings.<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-troubleshoot-common-page-rule-issues\">How to Troubleshoot Common Page Rule Issues<\/h3><p>Some issues may occur when setting up a page rule on your website. The most common is incorrect DNS settings. If your domain isn&rsquo;t proxied and doesn&rsquo;t point to Cloudflare, the rules won&rsquo;t work. To solve it, ensure it is connected to <a href=\"https:\/\/developers.cloudflare.com\/dns\/manage-dns-records\/how-to\/create-dns-records\" target=\"_blank\" rel=\"noopener\">Cloudflare&rsquo;s nameservers<\/a>.<\/p><p>A page rule may lead to an HTTP 500 internal server error due to a configuration issue. When using two wildcards, you may add the $2 placeholder on the second wildcard.<\/p><p>However, if you remove one of the wildcards when updating the rule, the placeholder will no longer be applicable, and it will trigger the error. To resolve it, update the page rule to remove the placeholder. If there&rsquo;s only one wildcard, use $1 instead.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Page rules let you customize Cloudflare&rsquo;s functionality to match your needs. It helps improve site performance, reliability, security, and user experience. You can also modify, remove, and prioritize the rules from the most to the least specific setting.<\/p><p>We have discussed the 13 most common rules for your website, including how to forward URLs, always use a secure connection, cache all contents, and enable email obfuscation.<\/p><p>We hope this article has helped you understand and configure Cloudflare Page Rules. If you have any questions or suggestions, leave them in the comments section below.<\/p><h2 class=\"wp-block-heading\" id=\"h-cloudflare-page-rules-faq\">Cloudflare Page Rules FAQ<\/h2><p>Here are the most frequently asked questions about Cloudflare Page Rules:<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1679676809769\"><h3 class=\"schema-faq-question\">How Many Page Rules Can I Create?&nbsp;<\/h3> <p class=\"schema-faq-answer\">The number of rules you can create depends on your Cloudflare plan. For example, the free package allows users to create up to three rules. However, you can purchase up to 100 rules individually for all Cloudflare plans except Enterprise.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1679676818283\"><h3 class=\"schema-faq-question\">What Are the Best Cloudflare Page Rules for WordPress?<\/h3> <p class=\"schema-faq-answer\">For a WordPress site, we recommend setting up five essential page rules &ndash; securing the login page, forwarding XML-RPC URLs, encrypting email addresses, protecting the admin dashboard, and caching static elements.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1679676827916\"><h3 class=\"schema-faq-question\">What Do Asterisks in Cloudflare Page Rules Mean?<\/h3> <p class=\"schema-faq-answer\">Asterisks are used in any URL segment to match certain patterns. For instance, setting example.com\/shop* cache level to <strong>bypass<\/strong> means Cloudflare will not record the history data on all URLs with \/shop\/.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Using Cloudflare Page Rules is a great option for those looking to optimize their websites. It is a beginner-friendly method, as it is unnecessary to modify any code to enable it &ndash; Cloudflare dashboard has an easy-to-use menu for managing all settings. Page rules are available on all Cloudflare plans and can be used for [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/cloudflare-page-rules\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":298,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Setup Cloudflare Page Rules + Most Useful Rules","rank_math_description":"Cloudflare Page Rules changes Cloudflare settings and triggers actions for requests. Check this article to learn how to set up Page Rules.","rank_math_focus_keyword":"cloudflare page rules","footnotes":""},"categories":[22656,22657],"tags":[],"class_list":["post-81776","post","type-post","status-publish","format-standard","hentry","category-website","category-website-performance-optimization"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/cloudflare-page-rules","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/cloudflare-page-rules","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-create-and-edit-cloudflare-page-rules-the-most-common-rules-to-consider","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-create-and-edit-cloudflare-page-rules-the-most-common-rules-to-consider","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/cloudflare-page-rules","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/cloudflare-page-rules","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/cloudflare-page-rules","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/cloudflare-page-rules","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/81776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/298"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=81776"}],"version-history":[{"count":11,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/81776\/revisions"}],"predecessor-version":[{"id":137917,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/81776\/revisions\/137917"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=81776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=81776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=81776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}