Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to configure an Apache VirtualHost to redirect HTTP requests to HTTPS without an infinite redirect loop when using CloudFlare with Flexible SSL.

CloudFlare Flexible SSL Rewrite HTTPS for Apache

Requirements

  • Apache
  • CloudFlare
  • Flexible SSL
  • mod_rewrite

Rewrite Config

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP:CF-Visitor} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.