Mobile app version of vmapp.org
Login or Join
Kimberly868

: How to change whole folder from http to https The checkout/onepage is working with HTTPS. But, why checkout/cart is not? Here is fragment of the .htaccess: ############################################

@Kimberly868

Posted in: #Apache2 #Htaccess #Https #Magento #ModRewrite

The checkout/onepage is working with HTTPS. But, why checkout/cart is not?

Here is fragment of the .htaccess:

############################################
## enable rewrites

Options +FollowSymLinks
RewriteEngine on
# RewriteCond %{REQUEST_URI} checkout/onepage
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} checkout/
# RewriteRule ^(.*)$ %{HTTP_HOST}/ [R=301,L]
RewriteRule ^checkout/$ idfr.com/checkout/ [R=301,L]

############################################



Apache version: Apache/2.4.7 (Ubuntu)
operating system: Windows 8.1
indications in the log files; Main ErrorLog: "/var/log/apache2/error.log"

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Kimberly868

2 Comments

Sorted by latest first Latest Oldest Best

 

@Bryan171

I think this line might be the problem:

RewriteRule ^checkout/$ idfr.com/checkout/ [R=301,L]
----^ ----^


This line rewites the url if the url 'starts with' (^) and 'ends with' ($) the string 'checkout'. Because you have no wildcards like * or ., this line now means "literally checkout/, nothing else".

This means that checkout/ will match, but checkout/example will not, because it doesn't match the rewrite rule conditions.

# force ssl
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_URI} ^/checkout
RewriteRule ^(.*)$ %{SERVER_NAME}%{REQUEST_URI} [L,R=301]


This snippet does:


If we are HTTP (which uses port 80)
AND the url starts with /checkout (Depending on your server, the slash might not be needed)
->Redirect to https version

10% popularity Vote Up Vote Down


 

@BetL925

Place in your /checkout/ folder a htaccess with this content:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>


It will rewrite all requests, which aren't secure (not coming to port 443) to https-ed url.

Another way

Place at the beginning of your files onepage and cart following PHP code snippet:

<?php
if ($_SERVER["SERVER_PORT"] != 443) {
$redir = "Location: . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header($redir);
header("HTTP/1.1 301 Moved Permanently");
exit();
}
?>


which does the same.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme