HowTo

How to Use WordPress With Cloudflare the Right Way

How to Use WordPress With Cloudflare the Right Way

Cloudflare can make a WordPress site faster and safer for free. It can also cause redirect loops, broken logins, and a cached shopping cart showing someone else’s items — if it’s set up carelessly. The difference comes down to a handful of settings.

This guide shows how to run WordPress with Cloudflare the right way: why the pairing works, how to connect your domain, which SSL settings to use, caching rules for WordPress, and security features worth enabling.

Why pair WordPress with Cloudflare

  • Faster delivery: images, CSS, and JavaScript are served from data centers close to visitors.
  • Less load on your server: cached files don’t hit your hosting at all.
  • Security: DDoS protection, bot filtering, and a basic firewall.
  • Free SSL at the edge and fast DNS.

New to CDNs? Start with What Is a CDN and Does Your Site Need One?.

Connecting your domain

  1. Create a free Cloudflare account and add your domain.
  2. Review the imported DNS records carefully. Make sure your website records point to your hosting IP and that MX and mail records are present.
  3. Set website records (root and www) to Proxied (orange cloud). Keep mail-related records DNS only (grey cloud).
  4. Change your nameservers at your registrar to the two Cloudflare provides.
  5. Wait for Cloudflare to show the domain as active.

Weighing Cloudflare against your registrar’s DNS? See Cloudflare DNS vs Registrar DNS: Which Should You Use?.

SSL settings that avoid errors

This is where most problems happen. Under SSL/TLS → Overview:

  • Use Full (strict) when your host has a valid SSL certificate (most do, with free Let’s Encrypt). Traffic is encrypted all the way to your server.
  • Avoid Flexible. It encrypts only visitor-to-Cloudflare traffic. With WordPress forcing HTTPS, it often causes “too many redirects” errors.
  • Turn on Always Use HTTPS and Automatic HTTPS Rewrites.

Make sure both URLs in WordPress Settings → General use https://. Need a certificate on your host first? Read What Is SSL? How to Get HTTPS for Free.

Caching rules for WordPress

By default, Cloudflare caches static files but not HTML pages. If you add full-page caching, you must bypass the cache for:

  • /wp-admin/* and /wp-login.php
  • Logged-in users (cookies starting with wordpress_logged_in)
  • Cart, checkout, and account pages on WooCommerce sites

Easier options: Cloudflare’s APO for WordPress (a paid add-on that handles these rules automatically) or a caching plugin with Cloudflare integration. Purge the Cloudflare cache after major design changes. For plugin options, see Best WordPress Caching Plugins Compared.

Also install the official Cloudflare plugin or configure your server so WordPress sees real visitor IPs instead of Cloudflare’s. Many hosts do this automatically; otherwise security plugins and comment logs may show only Cloudflare addresses.

Security settings worth enabling

  • Bot Fight Mode to block simple bad bots (test it — it can occasionally affect legitimate tools).
  • A firewall rule that challenges visitors to /wp-login.php from countries where you have no staff.
  • Rate limiting on the login page if your plan includes it.
  • Security level set to medium, with “Under Attack” mode saved for emergencies.
  • DNSSEC with one click — see What Is DNSSEC and Should You Turn It On?.

Key takeaways

  • Use Full (strict) SSL to avoid redirect loops.
  • Proxy website records, but keep mail records DNS only.
  • Bypass cache for admin, logged-in users, and checkout pages.
  • Restore real visitor IPs and enable basic security rules.
Z
zasma171

Writes for Hostreta about the topics covered in this article.

Comments (0)

Your email address will not be published. Required fields are marked *

Recent Comments

No comments to show.
Ad · AdSense
Ad space 300×250
Affiliate links
Tools we recommend
Protect Your Website with Automated Daily Backups
$2.09
Get it
the easiest way to manage all of your social media accounts
$29
Get it
Starter Website Get online, properly
$249
Get it
google workspace Business Starter
$3.75
Get it
Nord Vpn Cybersecurity. Built for Everyday Use
$8.99
Get it

We may earn a commission on purchases made through these links, at no extra cost to you.

Ad · AdSense
Ad space 300×600
Ad · AdSense
Ad space 300×600

$ top hosting picks

affiliate
★★★★★

NovaHost

$2.95/mo,renews at $9.95
  • Free SSL + domain, first year
  • 1-click WordPress install
  • 24/7 chat, sub-5-min response
get this deal →
affiliate link · we may earn a commission
★★★★★

CloudRoot

$4.50/mo,renews at $12.95
  • Built-in CDN + caching
  • Daily backups, 30-day retention
  • Staging environments included
get this deal →
affiliate link · we may earn a commission
★★★★★

AI SiteBuilder

$1.49/mo,renews at $13.99
  • 5 Websites
  • Emails & Security Included
  • AI Website Builder for WordPress
get this deal →
affiliate link · we may earn a commission

Never miss a new article

Join thousands of developers and builders getting a weekly digest of the best tech articles.