Setting default WordPress in https:// and redirecting it to http:// and forwarding http:// to https:// in Cloudflare

  • Earlier i have set my default WordPress install to http:// and redirected it in Cloudflare to use Https SSL, but got several mixed content errors on browsers[stating requests for https is http].

  • So, fresh installed my whole wordpress to use https:// but i’m on a shared server with no SSL certificate installed, so now my whole site redirects to https:// and displays [Server not found error].

    Read More
  • I need to keep my wordpress in https:// only, in order to work with sitemaps and other plugins to access only to the https:// without conflicting.

– So, do i need to Re-direct all https:// to http:// in .htaccess file and later redirect the http:// into cloudflare to use https://, with being my default WordPress installed to be https://

  • Have used several rules in .htaccess but no avail, Let me know the exact rule to redirect all http:// to https://

    RewriteCond %{SERVER_PORT} ^443$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    
    #RewriteEngine On
    RewriteCond %{SERVER_PORT} 443
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    

Related posts

2 comments

  1. If your server don’t listen on the 443 Port, you can’t just redirect them that way.

    And if there is just an invalid certificate, there will always be the “invalid certificate” error on redirect. But it should work like this:

    RewriteEngine On
    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
    

    You should try to grab an valid certificate.
    https://letsencrypt.org/ and https://www.startssl.com/ are good ways to start for free.

  2. Did you fix the problem? Maybe you need to add this to your wp-config.php

    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
    $_SERVER['HTTPS']='on';
    

    It tells your wordpress virtual machine to use the (cloudflare) hostname on the wordpress server. If SSL is done by cloudflare this can work because traffic behind the LoadBalance ist non-ssl traffic. But I dont know Cloudflare details at all 😉

    Also, you need to set the wordpress homeurl and siteurl to the https domain which your users should see.

Comments are closed.