You are here:  » Adding SSL certificate with Cloudflare


Adding SSL certificate with Cloudflare

Submitted by macland on Tue, 2017-08-22 08:26 in

Has anyone succesfully managed to route their traffic through Cloudflare and add their free SSL certificate?

I have tried for a few hours now and I'm getting crazy, no matter what I do I seem to get stuck in a scenario where the site responds 200 both with and without httpS, or an eternal 301-redirect loop where the httpS-url redirects to itself :-(

Submitted by support on Tue, 2017-08-22 09:34

Hi,

If you revert to the scenario where both http and https work (200 response) then you should be able to do the redirect in your .htaccess, immediately after the RewriteEngine On line:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by macland on Wed, 2017-08-23 12:16

Yeah that's what I tried but got the infinite redirect loop.

I have managed to solve it now, apparently it a problem Cloudflare sometimes has, sol you need to make the httpS switch using Cloudflare page rules and then just leave the htaccess file more or less as it is :-)

Submitted by Retro135 on Fri, 2017-09-29 15:00

Tried this (only activating via CF), not adding code after Rewrite/Base. Also tried adding code. Lost PT section entirely except for index.php which works with https. I deleted canonical code in header. No luck. Also, the search section panel in Admin > categories_hierarchy_configure.php no longer displays. Rest of site working fine.

Submitted by Retro135 on Fri, 2017-09-29 15:06

I set up a page rule to turn off SSL just for the shops section, but then received the infinite redirect error. Had to turn on again. Most things working in Admin interface other than what I said in previous post.

Submitted by support on Fri, 2017-09-29 15:56

Hi,

The plugin generated pages (shops section in your installation) generates links to resources using the WordPress codex get_bloginfo() function ('wpurl' parameter) so this will return fully qualified URLs with either http or https exactly as per the WordPress Address (URL) setting (wp-admin > Settings > General).

If you could check that setting and make sure that the WordPress Address (URL) is using https that might make all the difference - having looked around the web and the Cloudflare support forum the redirect loop issue does seem to occur when a a local resource is included in the HTML output with a fully qualified URL beginning http:// when that same server is configured to redirect all http requests to https.

I'll review how local resource URLs are generated in the plugin with a view to using the ideal scenario of the "//" prefix which implies the same protocol over which the page was requested...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Sat, 2017-09-30 11:51

I'm not using Wordpress for PT, this is an installation in a directory of my site (example.com/shops/)

Submitted by Retro135 on Sat, 2017-09-30 21:53

Hi David,
A big NEVER MIND... I need to stop working at ungodly hours. I created an .htaccess file with the "RewriteCond %{HTTPS} off" etc. code to do a quick test & not have to restart server. If code works, I place in httpd.conf. Somehow forgot about this htaccess and drove myself bonkers. Deleted it, everything works perfectly. Didn't have to use any CF Page Rules. It's all good.