How to use CloudFlare on root domain (without www)

Because CloudFlare works through CNAMEs, CloudFlare cannot be enabled on the root domain, which is an A record. If you would like to use CloudFlare to accelerate and protect traffic going to the root domain, you must add a redirect in the .htaccess file to 'www'.  The "root" domain would be instead of 

As a reference, here is one example:

RewriteEngine On
# Rewrite added for CloudflareInstall -
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$$1 [R=301,L]
  • 1206 Users Found This Useful
Was this answer helpful?