Redirect HTTPS to HTTP in .htaccess

With few exceptions, my clients’ sites all go through SSL. But recently, the SSL certificate for one of the sites expired unexpectedly. I created a Cloudflare account and switched the DNS, but the https version of the site was broken while the DNS updated.

So…I switched the site to http, made absolute paths relative so that it would look the same either way, and then I added the code below to the .htaccess file to force https traffic to go to http.


# Redirect HTTPS to HTTP
RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


Then, once the DNS updated and the new cert was in affect, I removed that snippet and switched the site back to https.

>