Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not answering your question directly, but I feel I put it as an answer (plus it is too big to post as a comment).</p> <p>My advice: please stop playing with htaccess for this kind of task (<strong>force</strong> few URLs to use HTTPS and <strong>force</strong> the rest to use HTTP).</p> <p>The best way is to <strong>generate FULL URLs</strong> for all links (pages, not resources), <strong>where URL includes domain name and protocol</strong>. In this case all URLs will have proper protocol (HTTP/HTTPS) straight away. Of course: you can still fix (301 or 302 redirect) requests to supposed-to-be-https if they (for some strange reason) are requested via HTTP. That's where .htaccess can be safely and easily used.</p> <p>If user will request normal page (should be served over HTTP) via HTTPS -- then let him do it -- there is nothing wrong with that. Yes -- HTTPS requires a bit more resources on server side, but if you generate all links in such way, there will be virtually no such situations, unless user <strong>specifically</strong> changes protocol. Even if such one page will be served over HTTPS, the next "normal" link he click will be HTTP -- 1 extra HTTPS-based page view will not kill your server.</p> <p>I'm using this approach all the time when site is having secure area .. and based on the logs, we have less than 0.01% of ALL page views that were viewed/attempted to be viewed via "wrong" protocol -- vast majority of them were bots or attempts to hack/vulnerability search. </p> <p><em>Based on such stats I would say -- it is working perfectly.</em> yes -- you need to alter you code/templates a bit to implement this .. but it is much better than messing with .htaccess and mod_rewrite.</p> <hr> <p>In any case, here are the rules that would do the job for you:</p> <pre><code># force https for all URLs in /checkout RewriteCond %{HTTPS} =off RewriteRule ^checkout https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # don't do anything for images/css/js RewriteRule \.(gif|jpe?g|png|css|js)$ - [NC,L] # force http for all other URLs that are not in /checkout RewriteCond %{HTTPS} =on RewriteCond %{REQUEST_URI} !^/(checkout|index.php/checkout) RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # your other rules here, e.g.: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] </code></pre> <p>OR</p> <pre><code># force https for all URLs in /checkout RewriteCond %{HTTPS} =off RewriteRule ^checkout https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # do not do anything for already existing files RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule .+ - [L] # force http for all other URLs that are not in /checkout RewriteCond %{HTTPS} =on RewriteCond %{REQUEST_URI} !^/checkout RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # your other rules here, e.g.: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COHmm, for some reason I am still having an issue. The site in question is palatinehillsestatewinery.com and the issue is on the checkout. If you add some products and try to check out, you'll see the https issue. Basically, I don't see any https redirect with this code, and instead it seems to break my "remove index.php" rule, causing the url to look like this, without https: palatinehillsestatewinery.com/index.php/checkout Thoughts?
      singulars
    2. COI have modified condition: try `RewriteCond %{REQUEST_URI} !^/(checkout|index.php/checkout)` instead of `RewriteCond %{REQUEST_URI} !^/checkout` (yeah -- we have to consider already rewritten rule as well -- I did not paid enough attention to the fact that `/checkout/` is not REAL folder/file). Alternatively try 2nd variant (sorry -- code untested as I cannot connect to my Apache box right now, but should work fine).
      singulars
    3. COThis is an old answer, but a point worth bringing up is that if you are calling external libraries, as is common when littering a site with social media buttons, sometimes those cannot be over HTTPS, so you get browser errors of various types concerning loading unsecure content. Loading an entire site across HTTPS can make a more social web application rather difficult. In my case, my order page has no social integration, but the rest of the site does, so all but the order page needs to be in HTTP for the benefit of "The Social Web"™
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload