Jump to content

Forcing https://

Recommended Posts

Now that CloudFlare has free Universal SSL, I'd like to serve my site over https://

What is the recommended PW approach to do this? Is it just a matter of tweaking the .htaccess file to force https:// ? If so, how would I go about it?

With one little tweak -- adding an "s" to the force "www." rewrite rule -- I can successfully redirect from http://domain.com to https://www.domain.com:

  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

But how should I deal with the second scenario: redirecting from http://www.domain.com to http s://www.domain.com? Everything I've tried ends up in a redirect loop. 


Share this post

Link to post
Share on other sites

Thanks netcarver. Forcing https in the template's URLs tab does not seem to work, at least on 2.5.4 dev.

Share this post

Link to post
Share on other sites

Yes, I posted that as an issue on github - feel free to add a +1 over there to see if Ryan will bump its priority.

Share this post

Link to post
Share on other sites

Done, although I would rather do this in the .htaccess file if possible so that I can quickly turn SSL on or off, and not have to do it on each and every template. Thanks again anyway. 

Share this post

Link to post
Share on other sites

If you are using CloudFlare, all you need to do is change your CloudFlare config. You don't get true end-to-end https that way, just between the browser & CloudFlare - not between CloudFlare & your site.

My blog (see sig) does it that way (and you get SPDY as an added bonus).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Peter Knight
      Hi all
      My .htaccess file is correctly redirecting all requests to
      https:// www. That's great until I want to work locally.
      I thought I had seen a blog post by Ryan where there was a new config setting to ignore both of these if working from localhost?
      I can't find it now so wondering if I was imagining 😕
    • By Marco Angeli
      Hi there,
      I added a ssl certificate to my site and I'd like to redirect every single http url to its new https version
      So I added this code in the .htacces file, after the RewriteEngine On :
      Redirect 301 /about https://www.mysite.it/about
      Unfortunately this is now working: I get the "too many redirects" error.
      The following code works, but it's a bulk redirection to the home page, something I don't want for SEO reasons (https://moz.com/blog/save-your-website-with-redirects😞
      RewriteCond %{HTTP_HOST} mysite\.it [NC]
      RewriteCond %{SERVER_PORT} 80
      RewriteRule ^(.*)$ https://www.mysite.it/$1 [R,L]
      Any suggestions?
    • By cosmicsafari
      Hi all,
      Just a quick question, when using the multisite module is there anything different that needs to be done in order to setup HTTPS for each of the domains its serving?
      Would a single SSL certificate for the main domain be enough to cover the others aswell or would you need multiple ceritficates one for each domain the mutlisite setup uses?
    • By dweeda
      I installed an SSL Certificate, then edited my .htaccess file:
        # -----------------------------------------------------------------------------------------------
        # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
        # -----------------------------------------------------------------------------------------------
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
      by uncommenting out the Rewrite lines.
      Now I get 404 error pages when I try go to any .../processwire-master/<pagename>/
      This includes my admin page at .../processwire-master/processwire/, so i can't get into my admin.
      What else do I need to do?
  • Create New...